Program: 112681
Project: 112681
Buggy source:
/** 
 * - Launch the main process: spark context, kafkaInputDstream and siddhi CEP engine - Filter the incoming messages (kafka) by key in order to separate the different commands - Parse the request contained in the payload - execute related command for each request
 * @param sparkMaster
 * @param zkCluster
 * @param kafkaCluster
 * @param topics
 * @throws Exception
 */
private static void launchStratioStreamingEngine(Config config) throws Exception {
  cassandraCluster=config.getString("String_Node_Str");
  failOverEnabled=config.getBoolean("String_Node_Str");
  String kafkaCluster=config.getString("String_Node_Str");
  String zkCluster=config.getString("String_Node_Str");
  String elasticSearchUrl=config.getString("String_Node_Str");
  boolean enableAuditing=config.getBoolean("String_Node_Str");
  boolean enableStats=config.getBoolean("String_Node_Str");
  boolean printStreams=config.getBoolean("String_Node_Str");
  long streamingBatchTime=config.getDuration("String_Node_Str",TimeUnit.MILLISECONDS);
  String topics=BUS.TOPICS;
  ZKUtils.getZKUtils(zkCluster).createEphemeralZNode(STREAMING.ZK_BASE_PATH + "String_Node_Str" + "String_Node_Str",String.valueOf(System.currentTimeMillis()).getBytes());
  jssc=new JavaStreamingContext(config.getString("String_Node_Str"),StreamingEngine.class.getName(),new Duration(streamingBatchTime));
  jssc.sparkContext().getConf().setJars(JavaStreamingContext.jarOfClass(StreamingEngine.class));
  KeepPayloadFromMessageFunction keepPayloadFromMessageFunction=new KeepPayloadFromMessageFunction();
  CreateStreamFunction createStreamFunction=new CreateStreamFunction(getSiddhiManager(),zkCluster);
  AlterStreamFunction alterStreamFunction=new AlterStreamFunction(getSiddhiManager(),zkCluster);
  InsertIntoStreamFunction insertIntoStreamFunction=new InsertIntoStreamFunction(getSiddhiManager(),zkCluster);
  AddQueryToStreamFunction addQueryToStreamFunction=new AddQueryToStreamFunction(getSiddhiManager(),zkCluster);
  ListenStreamFunction listenStreamFunction=new ListenStreamFunction(getSiddhiManager(),zkCluster,kafkaCluster);
  CollectRequestForStatsFunction collectRequestForStatsFunction=new CollectRequestForStatsFunction(getSiddhiManager(),zkCluster,kafkaCluster);
  ListStreamsFunction listStreamsFunction=new ListStreamsFunction(getSiddhiManager(),zkCluster);
  SaveRequestsToAuditLogFunction saveRequestsToAuditLogFunction=new SaveRequestsToAuditLogFunction(getSiddhiManager(),zkCluster,kafkaCluster,cassandraCluster,enableAuditing);
  SaveToCassandraStreamFunction saveToCassandraStreamFunction=new SaveToCassandraStreamFunction(getSiddhiManager(),zkCluster,cassandraCluster);
  HostAndPort elasticSearchConnectionData=HostAndPort.fromString(elasticSearchUrl);
  IndexStreamFunction indexStreamFunction=new IndexStreamFunction(getSiddhiManager(),zkCluster,elasticSearchConnectionData.getHostText(),elasticSearchConnectionData.getPortOrDefault(9300));
  Map<String,Integer> topicMap=new HashMap<String,Integer>();
  String[] topic_list=topics.split("String_Node_Str");
  HostAndPort kafkaConnectionData=HostAndPort.fromString(kafkaCluster);
  TopicService topicService=new KafkaTopicService(zkCluster,kafkaConnectionData.getHostText(),kafkaConnectionData.getPortOrDefault(9092),config.getInt("String_Node_Str"),config.getInt("String_Node_Str"));
  for (  String topic : topic_list) {
    topicService.createTopicIfNotExist(topic,config.getInt("String_Node_Str"),config.getInt("String_Node_Str"));
    Integer partitions=topicService.getNumPartitionsForTopic(topic);
    topicMap.put(topic,partitions);
  }
  JavaPairDStream<String,String> messages=KafkaUtils.createStream(jssc,zkCluster,BUS.STREAMING_GROUP_ID,topicMap);
  messages.cache();
  JavaDStream<StratioStreamingMessage> create_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.CREATE)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> alter_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.ALTER)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> insert_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.MANIPULATION.INSERT)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> add_query_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.ADD_QUERY)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> remove_query_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.REMOVE_QUERY)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> listen_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.LISTEN)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> stop_listen_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.STOP_LISTEN)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> saveToCassandra_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.SAVETO_CASSANDRA)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> stop_saveToCassandra_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.STOP_SAVETO_CASSANDRA)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> streamToIndexer_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.INDEX)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> stopStreamToIndexer_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.STOP_INDEX)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> list_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.MANIPULATION.LIST)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> drop_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.DROP)).map(keepPayloadFromMessageFunction);
  create_requests.foreachRDD(createStreamFunction);
  alter_requests.foreachRDD(alterStreamFunction);
  insert_requests.foreachRDD(insertIntoStreamFunction);
  add_query_requests.foreachRDD(addQueryToStreamFunction);
  remove_query_requests.foreachRDD(addQueryToStreamFunction);
  listen_requests.foreachRDD(listenStreamFunction);
  stop_listen_requests.foreachRDD(listenStreamFunction);
  saveToCassandra_requests.foreachRDD(saveToCassandraStreamFunction);
  stop_saveToCassandra_requests.foreach(saveToCassandraStreamFunction);
  streamToIndexer_requests.foreachRDD(indexStreamFunction);
  stopStreamToIndexer_requests.foreachRDD(indexStreamFunction);
  list_requests.foreachRDD(listStreamsFunction);
  drop_requests.foreachRDD(createStreamFunction);
  if (enableAuditing || enableStats) {
    JavaDStream<StratioStreamingMessage> allRequests=create_requests.union(alter_requests).union(insert_requests).union(add_query_requests).union(remove_query_requests).union(listen_requests).union(stop_listen_requests).union(saveToCassandra_requests).union(list_requests).union(drop_requests);
    if (enableAuditing) {
      allRequests.foreachRDD(saveRequestsToAuditLogFunction);
    }
    if (enableStats) {
      allRequests.foreachRDD(collectRequestForStatsFunction);
    }
  }
  StreamPersistence.saveStreamingEngineStatus(getSiddhiManager());
  if (printStreams) {
    messages.count().foreach(new Function<JavaRDD<Long>,Void>(){
      private static final long serialVersionUID=-2371501158355376325L;
      @Override public Void call(      JavaRDD<Long> arg0) throws Exception {
        StringBuffer sb=new StringBuffer();
        sb.append("String_Node_Str");
        sb.append("String_Node_Str");
        sb.append("String_Node_Str");
        sb.append(siddhiManager.getStreamDefinitions().size());
        sb.append("String_Node_Str");
        sb.append(getSiddhiManager().getSiddhiContext().getHazelcastInstance().getMap(STREAMING.STREAM_STATUS_MAP).size());
        sb.append("String_Node_Str");
        for (        StreamDefinition streamMetaData : getSiddhiManager().getStreamDefinitions()) {
          StringBuffer streamDefinition=new StringBuffer();
          streamDefinition.append(streamMetaData.getStreamId());
          for (          Attribute column : streamMetaData.getAttributeList()) {
            streamDefinition.append("String_Node_Str" + column.getName() + "String_Node_Str"+ column.getType());
          }
          if (StreamSharedStatus.getStreamStatus(streamMetaData.getStreamId(),getSiddhiManager()) != null) {
            HashMap<String,String> attachedQueries=StreamSharedStatus.getStreamStatus(streamMetaData.getStreamId(),getSiddhiManager()).getAddedQueries();
            streamDefinition.append("String_Node_Str" + attachedQueries.size() + "String_Node_Str");
            for (            String queryId : attachedQueries.keySet()) {
              streamDefinition.append(queryId + "String_Node_Str");
            }
            streamDefinition.append("String_Node_Str" + StreamSharedStatus.getStreamStatus(streamMetaData.getStreamId(),getSiddhiManager()).isUserDefined() + "String_Node_Str");
            streamDefinition.append("String_Node_Str" + StreamSharedStatus.getStreamStatus(streamMetaData.getStreamId(),getSiddhiManager()).isActionEnabled(StreamAction.LISTEN) + "String_Node_Str");
          }
          sb.append("String_Node_Str".concat(streamDefinition.toString()).concat("String_Node_Str"));
        }
        sb.append("String_Node_Str");
        logger.info(sb.toString());
        StreamPersistence.saveStreamingEngineStatus(getSiddhiManager());
        return null;
      }
    }
);
  }
  jssc.start();
  logger.info("String_Node_Str",new Date());
  jssc.awaitTermination();
}

Fixed version (ground truth):
/** 
 * - Launch the main process: spark context, kafkaInputDstream and siddhi CEP engine - Filter the incoming messages (kafka) by key in order to separate the different commands - Parse the request contained in the payload - execute related command for each request
 * @param sparkMaster
 * @param zkCluster
 * @param kafkaCluster
 * @param topics
 * @throws Exception
 */
private static void launchStratioStreamingEngine(Config config) throws Exception {
  cassandraCluster=config.getString("String_Node_Str");
  failOverEnabled=config.getBoolean("String_Node_Str");
  String kafkaCluster=config.getString("String_Node_Str");
  String zkCluster=config.getString("String_Node_Str");
  String elasticSearchUrl=config.getString("String_Node_Str");
  boolean enableAuditing=config.getBoolean("String_Node_Str");
  boolean enableStats=config.getBoolean("String_Node_Str");
  boolean printStreams=config.getBoolean("String_Node_Str");
  long streamingBatchTime=config.getDuration("String_Node_Str",TimeUnit.MILLISECONDS);
  String topics=BUS.TOPICS;
  ZKUtils.getZKUtils(zkCluster).createEphemeralZNode(STREAMING.ZK_BASE_PATH + "String_Node_Str" + "String_Node_Str",String.valueOf(System.currentTimeMillis()).getBytes());
  jssc=new JavaStreamingContext(config.getString("String_Node_Str"),StreamingEngine.class.getName(),new Duration(streamingBatchTime));
  jssc.sparkContext().getConf().setJars(JavaStreamingContext.jarOfClass(StreamingEngine.class));
  KeepPayloadFromMessageFunction keepPayloadFromMessageFunction=new KeepPayloadFromMessageFunction();
  CreateStreamFunction createStreamFunction=new CreateStreamFunction(getSiddhiManager(),zkCluster);
  AlterStreamFunction alterStreamFunction=new AlterStreamFunction(getSiddhiManager(),zkCluster);
  InsertIntoStreamFunction insertIntoStreamFunction=new InsertIntoStreamFunction(getSiddhiManager(),zkCluster);
  AddQueryToStreamFunction addQueryToStreamFunction=new AddQueryToStreamFunction(getSiddhiManager(),zkCluster);
  ListenStreamFunction listenStreamFunction=new ListenStreamFunction(getSiddhiManager(),zkCluster,kafkaCluster);
  CollectRequestForStatsFunction collectRequestForStatsFunction=new CollectRequestForStatsFunction(getSiddhiManager(),zkCluster,kafkaCluster);
  ListStreamsFunction listStreamsFunction=new ListStreamsFunction(getSiddhiManager(),zkCluster);
  SaveRequestsToAuditLogFunction saveRequestsToAuditLogFunction=new SaveRequestsToAuditLogFunction(getSiddhiManager(),zkCluster,kafkaCluster,cassandraCluster,enableAuditing);
  SaveToCassandraStreamFunction saveToCassandraStreamFunction=new SaveToCassandraStreamFunction(getSiddhiManager(),zkCluster,cassandraCluster);
  HostAndPort elasticSearchConnectionData=HostAndPort.fromString(elasticSearchUrl);
  IndexStreamFunction indexStreamFunction=new IndexStreamFunction(getSiddhiManager(),zkCluster,elasticSearchConnectionData.getHostText(),elasticSearchConnectionData.getPortOrDefault(9300));
  Map<String,Integer> topicMap=new HashMap<String,Integer>();
  String[] topic_list=topics.split("String_Node_Str");
  HostAndPort kafkaConnectionData=HostAndPort.fromString(kafkaCluster);
  TopicService topicService=new KafkaTopicService(zkCluster,kafkaConnectionData.getHostText(),kafkaConnectionData.getPortOrDefault(9092),config.getInt("String_Node_Str"),config.getInt("String_Node_Str"));
  for (  String topic : topic_list) {
    topicService.createTopicIfNotExist(topic,config.getInt("String_Node_Str"),config.getInt("String_Node_Str"));
    Integer partitions=topicService.getNumPartitionsForTopic(topic);
    if (partitions == 0) {
      partitions=config.getInt("String_Node_Str");
    }
    topicMap.put(topic,partitions);
  }
  JavaPairDStream<String,String> messages=KafkaUtils.createStream(jssc,zkCluster,BUS.STREAMING_GROUP_ID,topicMap);
  messages.cache();
  JavaDStream<StratioStreamingMessage> create_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.CREATE)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> alter_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.ALTER)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> insert_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.MANIPULATION.INSERT)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> add_query_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.ADD_QUERY)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> remove_query_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.REMOVE_QUERY)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> listen_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.LISTEN)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> stop_listen_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.STOP_LISTEN)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> saveToCassandra_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.SAVETO_CASSANDRA)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> stop_saveToCassandra_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.STOP_SAVETO_CASSANDRA)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> streamToIndexer_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.INDEX)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> stopStreamToIndexer_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.ACTION.STOP_INDEX)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> list_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.MANIPULATION.LIST)).map(keepPayloadFromMessageFunction);
  JavaDStream<StratioStreamingMessage> drop_requests=messages.filter(new FilterMessagesByOperationFunction(STREAM_OPERATIONS.DEFINITION.DROP)).map(keepPayloadFromMessageFunction);
  create_requests.foreachRDD(createStreamFunction);
  alter_requests.foreachRDD(alterStreamFunction);
  insert_requests.foreachRDD(insertIntoStreamFunction);
  add_query_requests.foreachRDD(addQueryToStreamFunction);
  remove_query_requests.foreachRDD(addQueryToStreamFunction);
  listen_requests.foreachRDD(listenStreamFunction);
  stop_listen_requests.foreachRDD(listenStreamFunction);
  saveToCassandra_requests.foreachRDD(saveToCassandraStreamFunction);
  stop_saveToCassandra_requests.foreach(saveToCassandraStreamFunction);
  streamToIndexer_requests.foreachRDD(indexStreamFunction);
  stopStreamToIndexer_requests.foreachRDD(indexStreamFunction);
  list_requests.foreachRDD(listStreamsFunction);
  drop_requests.foreachRDD(createStreamFunction);
  if (enableAuditing || enableStats) {
    JavaDStream<StratioStreamingMessage> allRequests=create_requests.union(alter_requests).union(insert_requests).union(add_query_requests).union(remove_query_requests).union(listen_requests).union(stop_listen_requests).union(saveToCassandra_requests).union(list_requests).union(drop_requests);
    if (enableAuditing) {
      allRequests.foreachRDD(saveRequestsToAuditLogFunction);
    }
    if (enableStats) {
      allRequests.foreachRDD(collectRequestForStatsFunction);
    }
  }
  StreamPersistence.saveStreamingEngineStatus(getSiddhiManager());
  if (printStreams) {
    messages.count().foreach(new Function<JavaRDD<Long>,Void>(){
      private static final long serialVersionUID=-2371501158355376325L;
      @Override public Void call(      JavaRDD<Long> arg0) throws Exception {
        StringBuffer sb=new StringBuffer();
        sb.append("String_Node_Str");
        sb.append("String_Node_Str");
        sb.append("String_Node_Str");
        sb.append(siddhiManager.getStreamDefinitions().size());
        sb.append("String_Node_Str");
        sb.append(getSiddhiManager().getSiddhiContext().getHazelcastInstance().getMap(STREAMING.STREAM_STATUS_MAP).size());
        sb.append("String_Node_Str");
        for (        StreamDefinition streamMetaData : getSiddhiManager().getStreamDefinitions()) {
          StringBuffer streamDefinition=new StringBuffer();
          streamDefinition.append(streamMetaData.getStreamId());
          for (          Attribute column : streamMetaData.getAttributeList()) {
            streamDefinition.append("String_Node_Str" + column.getName() + "String_Node_Str"+ column.getType());
          }
          if (StreamSharedStatus.getStreamStatus(streamMetaData.getStreamId(),getSiddhiManager()) != null) {
            HashMap<String,String> attachedQueries=StreamSharedStatus.getStreamStatus(streamMetaData.getStreamId(),getSiddhiManager()).getAddedQueries();
            streamDefinition.append("String_Node_Str" + attachedQueries.size() + "String_Node_Str");
            for (            String queryId : attachedQueries.keySet()) {
              streamDefinition.append(queryId + "String_Node_Str");
            }
            streamDefinition.append("String_Node_Str" + StreamSharedStatus.getStreamStatus(streamMetaData.getStreamId(),getSiddhiManager()).isUserDefined() + "String_Node_Str");
            streamDefinition.append("String_Node_Str" + StreamSharedStatus.getStreamStatus(streamMetaData.getStreamId(),getSiddhiManager()).isActionEnabled(StreamAction.LISTEN) + "String_Node_Str");
          }
          sb.append("String_Node_Str".concat(streamDefinition.toString()).concat("String_Node_Str"));
        }
        sb.append("String_Node_Str");
        logger.info(sb.toString());
        StreamPersistence.saveStreamingEngineStatus(getSiddhiManager());
        return null;
      }
    }
);
  }
  jssc.start();
  logger.info("String_Node_Str",new Date());
  jssc.awaitTermination();
}