當前位置: 首頁>>代碼示例>>Java>>正文


Java TopologyContext類代碼示例

本文整理匯總了Java中backtype.storm.task.TopologyContext的典型用法代碼示例。如果您正苦於以下問題:Java TopologyContext類的具體用法?Java TopologyContext怎麽用?Java TopologyContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TopologyContext類屬於backtype.storm.task包,在下文中一共展示了TopologyContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: prepare

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
@Override
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
    //for backward compatibility.
    if(mapper == null) {
        this.mapper = new FieldNameBasedTupleToKafkaMapper<K,V>();
    }

    //for backward compatibility.
    if(topicSelector == null) {
        this.topicSelector = new DefaultTopicSelector((String) stormConf.get(TOPIC));
    }

    Map configMap = (Map) stormConf.get(KAFKA_BROKER_PROPERTIES);
    Properties properties = new Properties();
    properties.putAll(configMap);
    ProducerConfig config = new ProducerConfig(properties);
    producer = new Producer<K, V>(config);
    this.collector = collector;
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:20,代碼來源:KafkaBolt.java

示例2: prepare

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
@Override
public void prepare(Map map, Object conf, TopologyContext topologyContext, IErrorReporter iErrorReporter) {
    Map<String, Object> config = (Map<String, Object>) conf;
    RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    client = CuratorFrameworkFactory.newClient(config.get("zookeeper").toString(), retryPolicy);
    client.start();


    try {
        if (client.checkExists().forPath("/consumers/rb-storm") == null) {
            client.create().creatingParentsIfNeeded().forPath("/consumers/rb-storm");
            System.out.println("Creating /consumers/rb-storm path ...");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:19,代碼來源:KafkaConsumerMonitorMetrics.java

示例3: prepare

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
@Override
public void prepare(Map stormConf, Object registrationArgument, TopologyContext context,
                    final IErrorReporter errorReporter) {

    LOG.info("Initializing the " + getClass().getCanonicalName());

    this.graphitePath = getConfiguredGraphitBasePath(stormConf);
    if (!stormConf.containsKey(CONF_MONITORING_GRAPHITE_SERVER)) {
        throw new RuntimeException("Missing graphite configuration. You need to specify the server and the port" +
                "under which the graphite server can be reached. Example: " + CONF_MONITORING_GRAPHITE_SERVER
                + "=graphite.yourdomain.com:2003");
    }
    this.graphiteConnection = (String) stormConf.get(CONF_MONITORING_GRAPHITE_SERVER);

    getGraphiteWriter();

    this.metricsToProcess = new HashMap<>();
    this.metricsToProcess.put(MonitoringMetricsCollectionHook.METRIC_COMPLETE_LATENCY, new AverageAggregator());
    this.metricsToProcess.put(MonitoringMetricsCollectionHook.METRIC_THROUGHPUT, new SumAggregator());
    this.metricsToProcess.put(MonitoringMetricsCollectionHook.METRIC_WORKER_CPU_LOAD, new SumAggregator());
    this.metricsToProcess.put(MonitoringMetricsCollectionHook.METRIC_WORKER_NETWORK_BYTES, new SumAggregator());
}
 
開發者ID:uzh,項目名稱:storm-scheduler,代碼行數:23,代碼來源:MonitoringMetricsToGraphiteWriter.java

示例4: prepare

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
public void prepare(Map map, TopologyContext topologyContext, OutputCollector collector) {
    this.collector = collector;
    final Configuration hbConfig = HBaseConfiguration.create();
    
    Map<String, Object> conf = (Map<String, Object>)map.get(this.configKey);
    if(conf == null) {
        throw new IllegalArgumentException("HBase configuration not found using key '" + this.configKey + "'");
    }
    if(conf.get("hbase.rootdir") == null) {
        LOG.warn("No 'hbase.rootdir' value found in configuration! Using HBase defaults.");
    }
    for(String key : conf.keySet()) {
        hbConfig.set(key, String.valueOf(conf.get(key)));
    }

    this.hBaseClient = new HBaseClient(conf, hbConfig, tableName);
}
 
開發者ID:mengzhiyi,項目名稱:storm-hbase-1.0.x,代碼行數:18,代碼來源:AbstractHBaseBolt.java

示例5: prepare

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
@Override
public void prepare(Map stormConf, TopologyContext context) {
	mapper = new ObjectMapper();
	this.configParams = (JSONObject) new JSONObject(this.config).get("params");
       try {
		this.configMap = mapper.readValue(this.config,new TypeReference<Map<String, Object>>() {});
		mapParams = (Map<String,Object>) configMap.get("params");
	} catch (IOException e) {
		e.printStackTrace();
	}

	field = getParam("field1", true);
	operator = getParam("operator", true);
	field2 = getParam("field2", true);
	entity = getParam("entity");

}
 
開發者ID:telefonicaid,項目名稱:fiware-sinfonier,代碼行數:18,代碼來源:ConditionalFields.java

示例6: prepare

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
@Override
public void prepare(Map stormConf, TopologyContext context) {

	mapper = new ObjectMapper();
	this.configParams = (JSONObject) new JSONObject(this.config).get("params");
       try {
		this.configMap = mapper.readValue(this.config,new TypeReference<Map<String, Object>>() {});
		mapParams = (Map<String,Object>) configMap.get("params");
	} catch (IOException e) {
		e.printStackTrace();
	}

	field = getParam("field", true);
	operator = (String) getParam("operator", true);
	value = (String) getParam("value", true);
	entity = (String) getParam("value");

	if (operator.equals("RegexExpression")) {
		pattern = Pattern.compile(value, Pattern.DOTALL);
	}

}
 
開發者ID:telefonicaid,項目名稱:fiware-sinfonier,代碼行數:23,代碼來源:Conditional.java

示例7: open

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
public void open(Map conf, TopologyContext ctx, SpoutOutputCollector collector) {
	this.collector = collector;
	this.history = new ProcessedHistory();
	this.subreddit = (String) conf.get("subreddit");
	
	try {
		this.subredditCommentsfeedURL = new URL((String)conf.get("feedURL"));
	} catch (MalformedURLException e) {
		throw new RuntimeException(e);
	}
	LOG.info("Spout subreddit:{} feedURL:{}", this.subreddit, this.subredditCommentsfeedURL);
	
	if (conf.containsKey("sentimentData")) {
		LOG.info("Spouts can also see sentimentData");
	}
}
 
開發者ID:pathbreak,項目名稱:reddit-sentiment-storm,代碼行數:17,代碼來源:SubredditCommentsSpout.java

示例8: prepare

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
public void prepare(Map conf, TopologyContext ctx, OutputCollector collector) {
	
	this.collector = collector;
	this.myId = ctx.getThisComponentId() + "-" + ctx.getThisTaskId();
	
	this.summary = new Summary();
	
	this.publisher = new ZkPublisher();
	try {
		this.publisher.init(conf);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
	
	this.lastPublishedTimestamp = 0;
}
 
開發者ID:pathbreak,項目名稱:reddit-sentiment-storm,代碼行數:17,代碼來源:SummarizerBolt.java

示例9: open

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
/**
 * Open file with stock tick data and read into List object.
 */
@Override
public void open(Map map,
                 TopologyContext context,
                 SpoutOutputCollector outputCollector) {
  this.outputCollector = outputCollector;

  try {
    ticks = 
      IOUtils.readLines(ClassLoader.getSystemResourceAsStream(
 "NASDAQ_daily_prices_A.csv"),
        Charset.defaultCharset().name());
  } catch (IOException e) {
      throw new RuntimeException(e);
  }
}
 
開發者ID:amitchmca,項目名稱:hadooparchitecturebook,代碼行數:19,代碼來源:StockTicksSpout.java

示例10: open

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
	try {
		_collector = collector;

		ru = new RedisUtil();
		redis = ru.getJedisInstance();

		SchedulerFactory schedulerFactory = new StdSchedulerFactory();
		Scheduler scheduler = schedulerFactory.getScheduler();
		_qManager = new QuartzManager();
		_qManager.setScheduler(scheduler);
		PlatformUtils.initRegisterProject(_qManager);
		scheduler.start();

		//init Hbase tables
		CreateTable.initHbaseTable();
	}catch(Exception ex){
		logger.error("error:"+MySysLogger.formatException(ex));
		ex.printStackTrace();
	}
}
 
開發者ID:cutoutsy,項目名稱:miner,代碼行數:22,代碼來源:BeginSpout.java

示例11: open

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
public void open(Map conf, TopologyContext context,
                 SpoutOutputCollector collector) {
    queue = new LinkedBlockingQueue<String>(1000);
    this.collector = collector;

    StatusListener listener = new StatusListener() {
        public void onStatus(Status status) {
            queue.offer(TwitterObjectFactory.getRawJSON(status));
        }

        public void onDeletionNotice(StatusDeletionNotice sdn) { }
        public void onTrackLimitationNotice(int i) { }
        public void onScrubGeo(long l, long l1) { }
        public void onStallWarning(StallWarning stallWarning) { }
        public void onException(Exception e) { }
    };

    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setJSONStoreEnabled(true);

    TwitterStreamFactory factory = new TwitterStreamFactory(cb.build());
    twitterStream = factory.getInstance();
    twitterStream.addListener(listener);
    twitterStream.filter(new FilterQuery().language("en").track("trump"));
}
 
開發者ID:mayconbordin,項目名稱:erad2016-streamprocessing,代碼行數:26,代碼來源:TwitterSpout.java

示例12: open

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
@Override
public void open(Map arg0, TopologyContext arg1, SpoutOutputCollector arg2) {
  /*
   * FileReader fileReader; try { fileReader = new
   * FileReader("C:/proj/Migration/apache-storm-0.9.4/apache-storm-0.9.4/logs/InPut.txt");
   * bufferedReader =new BufferedReader(fileReader); _collector= arg2; } catch
   * (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }
   */

  try {
    _collector = arg2;
    setUpConnection();
  } catch (JMSException e) {
    LOGGER.error(e);
  }

}
 
開發者ID:techysoul,項目名稱:java,代碼行數:18,代碼來源:DeliveryCheckSpout.java

示例13: open

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
	//fileName = (String) conf.get("file");
	this.collector = collector;

	try {
		reader = new BufferedReader(new FileReader(fileName));
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:PacktPublishing,項目名稱:Practical-Real-time-Processing-and-Analytics,代碼行數:12,代碼來源:FileSpout.java

示例14: TridentKafkaEmitter

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
public TridentKafkaEmitter(Map conf, TopologyContext context, TridentKafkaConfig config, String topologyInstanceId) {
    _config = config;
    _topologyInstanceId = topologyInstanceId;
    _connections = new DynamicPartitionConnections(_config, KafkaUtils.makeBrokerReader(conf, _config));
    _topologyName = (String) conf.get(Config.TOPOLOGY_NAME);
    _kafkaOffsetMetric = new KafkaUtils.KafkaOffsetMetric(_config.topic, _connections);
    context.registerMetric("kafkaOffset", _kafkaOffsetMetric, _config.metricsTimeBucketSizeInSecs);
    _kafkaMeanFetchLatencyMetric = context.registerMetric("kafkaFetchAvg", new MeanReducer(), _config.metricsTimeBucketSizeInSecs);
    _kafkaMaxFetchLatencyMetric = context.registerMetric("kafkaFetchMax", new MaxMetric(), _config.metricsTimeBucketSizeInSecs);
}
 
開發者ID:redBorder,項目名稱:rb-bi,代碼行數:11,代碼來源:TridentKafkaEmitter.java

示例15: prepare

import backtype.storm.task.TopologyContext; //導入依賴的package包/類
@Override
public void prepare(Map stormConf,
                    Object registrationArgument,
                    TopologyContext context,
                    IErrorReporter errorReporter) {
    this.stormId = context.getStormId();
    this.extemptMetrics = new HashSet<>();

    this.extemptMetrics.add(SchedulingMetricsCollectionHook.METRIC_EMITTED_MESSAGES);
}
 
開發者ID:uzh,項目名稱:storm-scheduler,代碼行數:11,代碼來源:LoggingMetricsConsumer.java


注:本文中的backtype.storm.task.TopologyContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。