From 913ff3a082760759f6bd354cc093dbb58953819d Mon Sep 17 00:00:00 2001 From: fjy Date: Thu, 7 Nov 2013 15:00:11 -0800 Subject: [PATCH] clean up code --- .../index/EventReceiverFirehoseFactory.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java b/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java index bc6a8c4b0fb..f2a3f575065 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/index/EventReceiverFirehoseFactory.java @@ -64,7 +64,7 @@ public class EventReceiverFirehoseFactory implements FirehoseFactory private final Optional chatHandlerProvider; @Deprecated - private final String oldServiceName; + private final String firehoseId; @JsonCreator public EventReceiverFirehoseFactory( @@ -76,18 +76,19 @@ public class EventReceiverFirehoseFactory implements FirehoseFactory @JacksonInject EventReceiverFirehoseFactoryConfig config ) { - this.serviceName = serviceName; - // This code is here for backwards compatibility if (serviceName == null) { - this.oldServiceName = String.format( + serviceName = String.format("%s:%s", config.getFirehoseIdPrefix(), Preconditions.checkNotNull(firehoseId, "firehoseId") ); + this.firehoseId = serviceName; } else { - this.oldServiceName = null; + this.firehoseId = null; } + this.serviceName = Preconditions.checkNotNull(serviceName, "serviceName"); + this.bufferSize = bufferSize == null || bufferSize <= 0 ? DEFAULT_BUFFER_SIZE : bufferSize; this.parser = Preconditions.checkNotNull(parser, "parser"); this.chatHandlerProvider = Optional.fromNullable(chatHandlerProvider); @@ -104,11 +105,6 @@ public class EventReceiverFirehoseFactory implements FirehoseFactory log.info("Found chathandler of class[%s]", chatHandlerProvider.get().getClass().getName()); chatHandlerProvider.get().register(serviceName, firehose); chatHandlerProvider.get().register(serviceName.replaceAll(".*:", ""), firehose); // rofl - - // backwards compatibility - if (oldServiceName != null) { - chatHandlerProvider.get().register(oldServiceName, firehose); - } } else { log.info("No chathandler detected"); } @@ -122,6 +118,14 @@ public class EventReceiverFirehoseFactory implements FirehoseFactory return serviceName; } + // Backward compatible + @Deprecated + @JsonProperty + public String getFirehoseId() + { + return firehoseId; + } + @JsonProperty public int getBufferSize() { @@ -235,11 +239,6 @@ public class EventReceiverFirehoseFactory implements FirehoseFactory if (chatHandlerProvider.isPresent()) { chatHandlerProvider.get().unregister(serviceName); - - // backwards compatibility - if (oldServiceName != null) { - chatHandlerProvider.get().unregister(oldServiceName); - } } } }