mirror of https://github.com/apache/druid.git
nodes no longer inherit from interfaces but instead extend classes
This commit is contained in:
parent
24564d73e1
commit
0ef40171a8
|
@ -30,7 +30,6 @@ import com.metamx.common.lifecycle.LifecycleStart;
|
|||
import com.metamx.common.lifecycle.LifecycleStop;
|
||||
import com.metamx.common.logger.Logger;
|
||||
import com.metamx.druid.http.RequestLogger;
|
||||
import com.metamx.druid.index.v1.serde.Registererer;
|
||||
import com.metamx.druid.initialization.Initialization;
|
||||
import com.metamx.druid.initialization.ServerConfig;
|
||||
import com.metamx.druid.initialization.ZkClientConfig;
|
||||
|
@ -62,7 +61,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
|
||||
/**
|
||||
*/
|
||||
public abstract class QueryableNode<T extends QueryableNode> implements RegisteringNode
|
||||
public abstract class QueryableNode<T extends QueryableNode> extends RegisteringNode
|
||||
{
|
||||
private final Logger log;
|
||||
|
||||
|
@ -91,6 +90,8 @@ public abstract class QueryableNode<T extends QueryableNode> implements Register
|
|||
ConfigurationObjectFactory configFactory
|
||||
)
|
||||
{
|
||||
super(jsonMapper, smileMapper);
|
||||
|
||||
this.log = log;
|
||||
this.configFactory = configFactory;
|
||||
this.props = props;
|
||||
|
@ -156,7 +157,6 @@ public abstract class QueryableNode<T extends QueryableNode> implements Register
|
|||
return (T) this;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T registerJacksonSubtype(Class<?>... clazzes)
|
||||
{
|
||||
|
@ -173,16 +173,6 @@ public abstract class QueryableNode<T extends QueryableNode> implements Register
|
|||
return (T) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandlers(Registererer... registererers)
|
||||
{
|
||||
for (Registererer registererer : registererers) {
|
||||
registererer.register();
|
||||
registererer.registerSubType(jsonMapper);
|
||||
registererer.registerSubType(smileMapper);
|
||||
}
|
||||
}
|
||||
|
||||
public Lifecycle getLifecycle()
|
||||
{
|
||||
return lifecycle;
|
||||
|
|
|
@ -20,10 +20,39 @@
|
|||
package com.metamx.druid;
|
||||
|
||||
import com.metamx.druid.index.v1.serde.Registererer;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface RegisteringNode
|
||||
public class RegisteringNode
|
||||
{
|
||||
public void registerHandlers(Registererer... registererers);
|
||||
public static void registerHandlers(Iterable<Registererer> registererers, Iterable<ObjectMapper> mappers)
|
||||
{
|
||||
for (Registererer registererer : registererers) {
|
||||
if (!doneRegister) {
|
||||
registererer.register();
|
||||
}
|
||||
for (ObjectMapper mapper : mappers) {
|
||||
registererer.registerSubType(mapper);
|
||||
}
|
||||
}
|
||||
doneRegister = true;
|
||||
}
|
||||
|
||||
private static boolean doneRegister = false;
|
||||
|
||||
private final ObjectMapper[] mappers;
|
||||
|
||||
public RegisteringNode(ObjectMapper... mappers)
|
||||
{
|
||||
this.mappers = mappers;
|
||||
}
|
||||
|
||||
public RegisteringNode registerHandlers(Registererer... registererers)
|
||||
{
|
||||
registerHandlers(Arrays.asList(registererers), Arrays.asList(mappers));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.metamx.common.ISE;
|
|||
import com.metamx.common.MapUtils;
|
||||
import com.metamx.common.guava.FunctionalIterable;
|
||||
import com.metamx.common.logger.Logger;
|
||||
import com.metamx.druid.RegisteringNode;
|
||||
import com.metamx.druid.index.v1.serde.Registererer;
|
||||
import com.metamx.druid.indexer.data.DataSpec;
|
||||
import com.metamx.druid.indexer.granularity.GranularitySpec;
|
||||
|
@ -58,6 +59,7 @@ import javax.annotation.Nullable;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -104,10 +106,8 @@ public class HadoopDruidIndexerConfig
|
|||
}
|
||||
}
|
||||
);
|
||||
for (Registererer registererer : registererers) {
|
||||
registererer.register();
|
||||
registererer.registerSubType(jsonMapper);
|
||||
}
|
||||
|
||||
RegisteringNode.registerHandlers(registererers, Arrays.asList(jsonMapper));
|
||||
}
|
||||
|
||||
final HadoopDruidIndexerConfig retVal = jsonMapper.convertValue(argSpec, HadoopDruidIndexerConfig.class);
|
||||
|
|
|
@ -4,8 +4,6 @@ import com.google.common.base.Preconditions;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.metamx.common.lifecycle.LifecycleStart;
|
||||
import com.metamx.common.lifecycle.LifecycleStop;
|
||||
import com.metamx.druid.RegisteringNode;
|
||||
import com.metamx.druid.index.v1.serde.Registererer;
|
||||
import org.codehaus.jackson.map.jsontype.NamedType;
|
||||
import org.joda.time.Interval;
|
||||
|
||||
|
@ -15,7 +13,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class HadoopDruidIndexerNode implements RegisteringNode
|
||||
public class HadoopDruidIndexerNode
|
||||
{
|
||||
public static Builder builder()
|
||||
{
|
||||
|
@ -61,15 +59,6 @@ public class HadoopDruidIndexerNode implements RegisteringNode
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandlers(Registererer... registererers)
|
||||
{
|
||||
for (Registererer registererer : registererers) {
|
||||
registererer.register();
|
||||
registererer.registerSubType(HadoopDruidIndexerConfig.jsonMapper);
|
||||
}
|
||||
}
|
||||
|
||||
@LifecycleStart
|
||||
public void start() throws Exception
|
||||
{
|
||||
|
|
|
@ -43,7 +43,6 @@ import com.metamx.druid.http.GuiceServletConfig;
|
|||
import com.metamx.druid.http.RedirectFilter;
|
||||
import com.metamx.druid.http.RedirectInfo;
|
||||
import com.metamx.druid.http.StatusServlet;
|
||||
import com.metamx.druid.index.v1.serde.Registererer;
|
||||
import com.metamx.druid.initialization.Initialization;
|
||||
import com.metamx.druid.initialization.ServerConfig;
|
||||
import com.metamx.druid.initialization.ServiceDiscoveryConfig;
|
||||
|
@ -109,7 +108,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class IndexerCoordinatorNode implements RegisteringNode
|
||||
public class IndexerCoordinatorNode extends RegisteringNode
|
||||
{
|
||||
private static final Logger log = new Logger(IndexerCoordinatorNode.class);
|
||||
|
||||
|
@ -146,6 +145,8 @@ public class IndexerCoordinatorNode implements RegisteringNode
|
|||
ConfigurationObjectFactory configFactory
|
||||
)
|
||||
{
|
||||
super(jsonMapper);
|
||||
|
||||
this.jsonMapper = jsonMapper;
|
||||
this.lifecycle = lifecycle;
|
||||
this.props = props;
|
||||
|
@ -185,15 +186,6 @@ public class IndexerCoordinatorNode implements RegisteringNode
|
|||
this.taskRunnerFactory = taskRunnerFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandlers(Registererer... registererers)
|
||||
{
|
||||
for (Registererer registererer : registererers) {
|
||||
registererer.register();
|
||||
registererer.registerSubType(jsonMapper);
|
||||
}
|
||||
}
|
||||
|
||||
public void init() throws Exception
|
||||
{
|
||||
scheduledExecutorFactory = ScheduledExecutors.createFactory(lifecycle);
|
||||
|
|
|
@ -80,7 +80,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
|
||||
/**
|
||||
*/
|
||||
public class WorkerNode implements RegisteringNode
|
||||
public class WorkerNode extends RegisteringNode
|
||||
{
|
||||
private static final Logger log = new Logger(WorkerNode.class);
|
||||
|
||||
|
@ -113,6 +113,8 @@ public class WorkerNode implements RegisteringNode
|
|||
ConfigurationObjectFactory configFactory
|
||||
)
|
||||
{
|
||||
super(jsonMapper);
|
||||
|
||||
this.jsonMapper = jsonMapper;
|
||||
this.lifecycle = lifecycle;
|
||||
this.props = props;
|
||||
|
@ -149,15 +151,6 @@ public class WorkerNode implements RegisteringNode
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHandlers(Registererer... registererers)
|
||||
{
|
||||
for (Registererer registererer : registererers) {
|
||||
registererer.register();
|
||||
registererer.registerSubType(jsonMapper);
|
||||
}
|
||||
}
|
||||
|
||||
public void init() throws Exception
|
||||
{
|
||||
initializeEmitter();
|
||||
|
|
Loading…
Reference in New Issue