Github user Thanu commented on a diff in the pull request: https://github.com/apache/stratos/pull/493#discussion_r45715705 --- Diff: components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/statistics/publisher/ThriftStatisticsPublisher.java --- @@ -61,54 +57,54 @@ public ThriftStatisticsPublisher(StreamDefinition streamDefinition, String thrif this.streamDefinition = streamDefinition; if (isPublisherEnabled()) { - this.enabled = true; + this.enabled = true; init(); } } private boolean isPublisherEnabled() { - boolean publisherEnabled = false; - for (ThriftClientInfo thriftClientInfo : thriftClientInfoList) { - publisherEnabled = thriftClientInfo.isStatsPublisherEnabled(); - if(publisherEnabled){ - break; - } - } - return publisherEnabled; - } - - private void init() { - + for (ThriftClientInfo thriftClientInfo : thriftClientInfoList) { + if (thriftClientInfo.isStatsPublisherEnabled()) { + return true; + } + } + return false; + } + + private void init() { + // Initialize load balancing data publisher loadBalancingDataPublisher = new LoadBalancingDataPublisher(getReceiverGroups()); + + //adding stream definition loadBalancingDataPublisher.addStreamDefinition(streamDefinition); } private ArrayList<ReceiverGroup> getReceiverGroups() { - - ArrayList<ReceiverGroup> receiverGroups = new ArrayList<ReceiverGroup>(); - + + ArrayList<ReceiverGroup> receiverGroups = new ArrayList<ReceiverGroup>(); + for (ThriftClientInfo thriftClientInfo : thriftClientInfoList) { - ArrayList<DataPublisherHolder> dataPublisherHolders = new ArrayList<DataPublisherHolder>(); - DataPublisherHolder aNode = new DataPublisherHolder(null, buildUrl(thriftClientInfo), thriftClientInfo.getUsername(), thriftClientInfo.getPassword()); - dataPublisherHolders.add(aNode); - ReceiverGroup group = new ReceiverGroup(dataPublisherHolders); - receiverGroups.add(group); - } - return receiverGroups; - - } - - private String buildUrl(ThriftClientInfo thriftClientInfo) { - String url = new StringBuilder() - .append("tcp://") - .append(thriftClientInfo.getIp()) - .append(":") - .append(thriftClientInfo.getPort()).toString(); - return url; - } - - @Override + ArrayList<DataPublisherHolder> dataPublisherHolders = new ArrayList<DataPublisherHolder>(); + DataPublisherHolder aNode = new DataPublisherHolder(null, buildUrl(thriftClientInfo), thriftClientInfo.getUsername(), thriftClientInfo.getPassword()); + dataPublisherHolders.add(aNode); + ReceiverGroup group = new ReceiverGroup(dataPublisherHolders); + receiverGroups.add(group); + } + return receiverGroups; + + } + + private String buildUrl(ThriftClientInfo thriftClientInfo) { + String url = new StringBuilder() + .append("tcp://") + .append(thriftClientInfo.getIp()) + .append(":") + .append(thriftClientInfo.getPort()).toString(); + return url; + } + --- End diff -- We are getting all thrift servers details from thrift-client-config.xml into thriftClientInfoList and creating thrift urls for each server. For each thrift URLs, we are creating DataPublisherHolder object as in line 89 and creating the ReceiverGroup and using that we are creating a Load Balancing type data publisher to publish data.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---