mirror of https://github.com/apache/kafka.git
KAFKA-9165: Fix jersey warnings in Trogdor (#7669)
Reviewers: David Arthur <mumrah@gmail.com>, Stanislav Kozlovski <stanislav_kozlovski@outlook.com>
This commit is contained in:
parent
7f5c380c34
commit
69a63304de
|
@ -248,7 +248,9 @@ public final class Agent {
|
|||
AgentRestResource resource = new AgentRestResource();
|
||||
log.info("Starting agent process.");
|
||||
final Agent agent = new Agent(platform, Scheduler.SYSTEM, restServer, resource);
|
||||
restServer.start(resource);
|
||||
AgentResourceBinder binder =
|
||||
new AgentResourceBinder(resource, AgentRestResource.class);
|
||||
restServer.start(binder);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
log.warn("Running agent shutdown hook.");
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.kafka.trogdor.agent;
|
||||
|
||||
import org.glassfish.jersey.internal.inject.AbstractBinder;
|
||||
|
||||
/**
|
||||
* This class implements a workaround for the Jersey bug which leads to
|
||||
* warning messages when registering a Resource object.
|
||||
* See https://github.com/eclipse-ee4j/jersey/issues/3700
|
||||
*
|
||||
* Unfortunately, this can't be common code shared with the Coordinator, because hk2/jersey
|
||||
* doesn't add new bindings for the same class.
|
||||
*/
|
||||
public class AgentResourceBinder extends AbstractBinder {
|
||||
private Object object;
|
||||
private Class clazz;
|
||||
|
||||
public AgentResourceBinder(Object object, Class clazz) {
|
||||
this.object = object;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void configure() {
|
||||
bind(object).to(clazz);
|
||||
}
|
||||
}
|
|
@ -170,7 +170,9 @@ public final class Coordinator {
|
|||
log.info("Starting coordinator process.");
|
||||
final Coordinator coordinator = new Coordinator(platform, Scheduler.SYSTEM,
|
||||
restServer, resource, ThreadLocalRandom.current().nextLong(0, Long.MAX_VALUE / 2));
|
||||
restServer.start(resource);
|
||||
CoordinatorResourceBinder binder =
|
||||
new CoordinatorResourceBinder(resource, CoordinatorRestResource.class);
|
||||
restServer.start(binder);
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
log.warn("Running coordinator shutdown hook.");
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.kafka.trogdor.coordinator;
|
||||
|
||||
import org.glassfish.jersey.internal.inject.AbstractBinder;
|
||||
|
||||
/**
|
||||
* This class implements a workaround for the Jersey bug which leads to
|
||||
* warning messages when registering a Resource object.
|
||||
* See https://github.com/eclipse-ee4j/jersey/issues/3700
|
||||
*
|
||||
* Unfortunately, this can't be common code shared with the Agent, because hk2/jersey
|
||||
* doesn't add new bindings for the same class.
|
||||
*/
|
||||
public class CoordinatorResourceBinder extends AbstractBinder {
|
||||
private Object object;
|
||||
private Class clazz;
|
||||
|
||||
public CoordinatorResourceBinder(Object object, Class clazz) {
|
||||
this.object = object;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void configure() {
|
||||
bind(object).to(clazz);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue