Java Code Examples for storm.trident.operation.TridentOperationContext

The following are top voted examples for showing how to use storm.trident.operation.TridentOperationContext. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: rb-bi   File: ProcessMse10Association.java   Source Code and License 6 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
    logger = RbLogger.getLogger(ProcessMse10Association.class.getName());

    cache = new HashMap<>();
    cache.put(0, "IDLE");
    cache.put(1, "AAA_PENDING");
    cache.put(2, "AUTHENTICATED");
    cache.put(3, "ASSOCIATED");
    cache.put(4, "POWERSAVE");
    cache.put(5, "DISASSOCIATED");
    cache.put(6, "TO_BE_DELETED");
    cache.put(7, "PROBING");
    cache.put(8, "BLACK_LISTED");
    cache.put(256, "WAIT_AUTHENTICATED");
    cache.put(257, "WAIT_ASSOCIATED");
}
 
Example 2
Project: rb-bi   File: GeoIpFunction.java   Source Code and License 6 votes vote down vote up
/**
 * Initializing the database reference and patterns.
 */
@Override
public void prepare(Map conf, TridentOperationContext context) {
    try {
        _city = new LookupService(CITY_DB_PATH, LookupService.GEOIP_MEMORY_CACHE);
        _city6 = new LookupService(CITY_V6_DB_PATH, LookupService.GEOIP_MEMORY_CACHE);
        _asn = new LookupService(ASN_DB_PATH, LookupService.GEOIP_MEMORY_CACHE);
        _asn6 = new LookupService(ASN_V6_DB_PATH, LookupService.GEOIP_MEMORY_CACHE);
        VALID_IPV4_PATTERN = Pattern.compile(ipv4Pattern, Pattern.CASE_INSENSITIVE);
        VALID_IPV6_PATTERN = Pattern.compile(ipv6Pattern, Pattern.CASE_INSENSITIVE);
    } catch (IOException ex) {
        Logger.getLogger(GeoIpFunction.class.getName()).log(Level.SEVERE, ex.toString());
    } catch (PatternSyntaxException e) {
        Logger.getLogger(GeoIpFunction.class.getName()).log(Level.SEVERE, "Unable to compile IP check patterns");
    }
}
 
Example 3
Project: tfidf-topology   File: DocumentFetchFunction.java   Source Code and License 6 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context){
    if (conf.get(backtype.storm.Config.TOPOLOGY_DEBUG).equals(true)) {
        testMode = true;
        CSVReader reader;
        try {
            reader = new CSVReader(new BufferedReader(
                    new InputStreamReader(
                            DocumentFetchFunction.class
                                    .getResourceAsStream("docs.csv"))));
            List<String[]> myEntries = reader.readAll();
            for(String[] row : myEntries){
                testData.put(row[0], row[1]);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
 
Example 4
Project: tfidf-topology   File: PersistDocumentFunction.java   Source Code and License 6 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
    try {
        String path = (String) conf.get("DOCUMENT_PATH");
        schema = Schema.parse(PersistDocumentFunction.class
                .getResourceAsStream("/document.avsc"));
        File file = new File(path);
        DatumWriter<GenericRecord> datumWriter = new GenericDatumWriter<GenericRecord>(schema);
        dataFileWriter = new DataFileWriter<GenericRecord>(datumWriter);
        if(file.exists())
            dataFileWriter.appendTo(file);
        else
            dataFileWriter.create(schema, file);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

}
 
Example 5
Project: rb-bi   File: ThroughputLoggingFilter.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
    _count = new HashMap<>();
    _sec_count = 0;
    _mean = 0;
    _totalMean = 0;
    System.out.println("Starting throughput metrics [ " + _position + " ]");
}
 
Example 6
Project: rb-bi   File: PostgreSQLocation.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
    // logger = RbLogger.getLogger(PostgreSQLocation.class.getName());
    PostgresqlManager.initConfig(uri, user, pass, updateTime, failUpdateTime);
    _manager = PostgresqlManager.getInstance();
    _manager.init();
}
 
Example 7
Project: jstorm-0.9.6.3-   File: ChainedAggregatorImpl.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
       _inputFactories = new ProjectionFactory[_inputFields.length];
       for(int i=0; i<_inputFields.length; i++) {
           _inputFactories[i] = context.makeProjectionFactory(_inputFields[i]);
           _aggs[i].prepare(conf, new TridentOperationContext(context, _inputFactories[i]));
       }
   }
 
Example 8
Project: jstorm-0.9.6.3-   File: AggregateProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Aggregate operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new FreshCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _agg.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 9
Project: jstorm-0.9.6.3-   File: StateQueryProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 10
Project: jstorm-0.9.6.3-   File: PartitionPersistProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Partition persist operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new FreshCollector(tridentContext);
    _updater.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 11
Project: jstorm-0.9.6.3-   File: EachProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Each operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new AppendCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 12
Project: web-crawler   File: KafkaProducerFilter.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
    Properties props = new Properties();
    props.put("metadata.broker.list", conf.get(CrawlerConfig.KAFKA_PRODUCER_HOST_NAME)+":"+conf.get( CrawlerConfig.KAFKA_PRODUCER_HOST_PORT) );
    props.put("serializer.class", "kafka.serializer.StringEncoder");
    this.producer = new kafka.javaapi.producer.Producer<String, String>(new ProducerConfig(props));
    this.kafkaTopic = (String) conf.get( CrawlerConfig.KAFKA_TOPIC_NAME );
}
 
Example 13
Project: web-crawler   File: URLFilter.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
    bloomFilter = new RedisBloomFilter<String>(Integer.parseInt(conf.get(CrawlerConfig.BLOOM_FILTER_EXPECTED_ELEMENT_COUNT).toString()),
                                                Double.parseDouble(conf.get(CrawlerConfig.BLOOM_FILTER_DESIRED_FALSE_POSITIVE).toString()),
                                                conf.get(CrawlerConfig.REDIS_HOST_NAME).toString(),
                                                Short.parseShort(conf.get(CrawlerConfig.REDIS_HOST_PORT).toString()),
                                                conf.get(CrawlerConfig.BLOOM_FILTER_NAME).toString()
                                                );
}
 
Example 14
Project: learn_jstorm   File: ChainedAggregatorImpl.java   Source Code and License 5 votes vote down vote up
public void prepare(Map conf, TridentOperationContext context) {
    _inputFactories = new ProjectionFactory[_inputFields.length];
    for(int i=0; i<_inputFields.length; i++) {
        _inputFactories[i] = context.makeProjectionFactory(_inputFields[i]);
        _aggs[i].prepare(conf, new TridentOperationContext(context, _inputFactories[i]));
    }
}
 
Example 15
Project: learn_jstorm   File: AggregateProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Aggregate operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new FreshCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _agg.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 16
Project: learn_jstorm   File: StateQueryProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 17
Project: learn_jstorm   File: PartitionPersistProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Partition persist operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new FreshCollector(tridentContext);
    _updater.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 18
Project: learn_jstorm   File: EachProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Each operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new AppendCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 19
Project: jstrom   File: ChainedAggregatorImpl.java   Source Code and License 5 votes vote down vote up
public void prepare(Map conf, TridentOperationContext context) {
    _inputFactories = new ProjectionFactory[_inputFields.length];
    for (int i = 0; i < _inputFields.length; i++) {
        _inputFactories[i] = context.makeProjectionFactory(_inputFields[i]);
        _aggs[i].prepare(conf, new TridentOperationContext(context, _inputFactories[i]));
    }
}
 
Example 20
Project: jstrom   File: AggregateProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("Aggregate operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new FreshCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _agg.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 21
Project: jstrom   File: StateQueryProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 22
Project: jstrom   File: PartitionPersistProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("Partition persist operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new FreshCollector(tridentContext);
    _updater.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 23
Project: jstrom   File: EachProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("Each operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new AppendCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 24
Project: Tstream   File: ChainedAggregatorImpl.java   Source Code and License 5 votes vote down vote up
public void prepare(Map conf, TridentOperationContext context) {
    _inputFactories = new ProjectionFactory[_inputFields.length];
    for(int i=0; i<_inputFields.length; i++) {
        _inputFactories[i] = context.makeProjectionFactory(_inputFields[i]);
        _aggs[i].prepare(conf, new TridentOperationContext(context, _inputFactories[i]));
    }
}
 
Example 25
Project: Tstream   File: AggregateProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Aggregate operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new FreshCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _agg.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 26
Project: Tstream   File: StateQueryProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 27
Project: Tstream   File: PartitionPersistProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Partition persist operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new FreshCollector(tridentContext);
    _updater.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 28
Project: Tstream   File: EachProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Each operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new AppendCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 29
Project: realtime-event-processing   File: KafkaProducerFilter.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
    Properties props = new Properties();
    props.put("metadata.broker.list", conf.get(CrawlerConfig.KAFKA_PRODUCER_HOST_NAME)+":"+conf.get( CrawlerConfig.KAFKA_PRODUCER_HOST_PORT) );
    props.put("serializer.class", "kafka.serializer.StringEncoder");
    this.producer = new kafka.javaapi.producer.Producer<String, String>(new ProducerConfig(props));
    this.kafkaTopic = (String) conf.get( CrawlerConfig.KAFKA_TOPIC_NAME );
}
 
Example 30
Project: realtime-event-processing   File: URLFilter.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
    bloomFilter = new RedisBloomFilter<String>(Integer.parseInt(conf.get(CrawlerConfig.BLOOM_FILTER_EXPECTED_ELEMENT_COUNT).toString()),
                                                Double.parseDouble(conf.get(CrawlerConfig.BLOOM_FILTER_DESIRED_FALSE_POSITIVE).toString()),
                                                conf.get(CrawlerConfig.REDIS_HOST_NAME).toString(),
                                                Short.parseShort(conf.get(CrawlerConfig.REDIS_HOST_PORT).toString()),
                                                conf.get(CrawlerConfig.BLOOM_FILTER_NAME).toString()
                                                );
}
 
Example 31
Project: storm-query-operators   File: Triple2Graph.java   Source Code and License 5 votes vote down vote up
@Override
	public void prepare(Map conf, TridentOperationContext context) {
		super.prepare(conf, context);
		graph = Factory.createDefaultGraph();
		// TODO: Get the triple pattern from the configuration/context 
		statementPattern = new SimpleSelector(null, 
				ResourceFactory.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
				ResourceFactory.createResource("http://purl.oclc.org/NET/ssnx/ssn#FeatureOfInterest")); 
//		System.out.println("PRINTED PATTERN: " + statementPattern.toString());
//		Statement aux = ResourceFactory.createStatement(ResourceFactory.createResource("http://earthquakes.linkeddata.es/1185937"), 
//				ResourceFactory.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), 
//				ResourceFactory.createResource("http://purl.oclc.org/NET/ssnx/ssn#FeatureOfInterest"));
//		System.out.println("PRINTED TRIPLE: " + aux);
//		System.out.println("MATCHING?? " + statementPattern.test(aux));
	}
 
Example 32
Project: incubator-storm   File: ChainedAggregatorImpl.java   Source Code and License 5 votes vote down vote up
public void prepare(Map conf, TridentOperationContext context) {
    _inputFactories = new ProjectionFactory[_inputFields.length];
    for(int i=0; i<_inputFields.length; i++) {
        _inputFactories[i] = context.makeProjectionFactory(_inputFields[i]);
        _aggs[i].prepare(conf, new TridentOperationContext(context, _inputFactories[i]));
    }
}
 
Example 33
Project: incubator-storm   File: AggregateProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Aggregate operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new FreshCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _agg.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 34
Project: incubator-storm   File: StateQueryProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 35
Project: incubator-storm   File: PartitionPersistProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Partition persist operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new FreshCollector(tridentContext);
    _updater.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 36
Project: incubator-storm   File: EachProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Each operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new AppendCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 37
Project: storm-resa   File: ChainedAggregatorImpl.java   Source Code and License 5 votes vote down vote up
public void prepare(Map conf, TridentOperationContext context) {
    _inputFactories = new ProjectionFactory[_inputFields.length];
    for(int i=0; i<_inputFields.length; i++) {
        _inputFactories[i] = context.makeProjectionFactory(_inputFields[i]);
        _aggs[i].prepare(conf, new TridentOperationContext(context, _inputFactories[i]));
    }
}
 
Example 38
Project: storm-resa   File: AggregateProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Aggregate operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new FreshCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _agg.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 39
Project: storm-resa   File: StateQueryProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 40
Project: storm-resa   File: PartitionPersistProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Partition persist operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new FreshCollector(tridentContext);
    _updater.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 41
Project: storm-resa   File: EachProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Each operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new AppendCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 42
Project: acromusashi-stream-ml   File: ApacheLogSplitFunction.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void prepare(@SuppressWarnings("rawtypes") Map conf, TridentOperationContext context)
{
    this.objectMapper = new ObjectMapper();
    this.javaDateFormat = new SimpleDateFormat(this.dateFormatStr);
}
 
Example 43
Project: acromusashi-stream-ml   File: KmeansCreator.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void prepare(Map conf, TridentOperationContext context)
{
    if (logger.isDebugEnabled() == true)
    {
        logger.debug("prepared started. taskIndex=" + context.getPartitionIndex()
                + ", taxkNum=" + context.numPartitions());
    }
}
 
Example 44
Project: acromusashi-stream-ml   File: KmeansUpdater.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void prepare(Map conf, TridentOperationContext context)
{
    // データ処理時のオブジェクト、バッチ処理時のオブジェクトが設定されている場合、初期化を行う。
    if (this.dataNotifier != null)
    {
        this.dataNotifier.initialize(conf, context);
    }
    if (this.batchNotifier != null)
    {
        this.batchNotifier.initialize(conf, context);
    }
}
 
Example 45
Project: acromusashi-stream-ml   File: LofUpdater.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void prepare(Map conf, TridentOperationContext context)
{
    // データ処理時のオブジェクト、バッチ処理時のオブジェクトが設定されている場合、初期化を行う。
    if (this.dataNotifier != null)
    {
        this.dataNotifier.initialize(conf, context);
    }
    if (this.batchNotifier != null)
    {
        this.batchNotifier.initialize(conf, context);
    }
}
 
Example 46
Project: acromusashi-stream-ml   File: LofResultPrinter.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void initialize(Map conf, TridentOperationContext context)
{
    // Do nothing.
}
 
Example 47
Project: acromusashi-stream-ml   File: LofModelPrinter.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void initialize(Map conf, TridentOperationContext context)
{
    // Do nothing.
}
 
Example 48
Project: acromusashi-stream-ml   File: LofPointCreator.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void prepare(Map conf, TridentOperationContext context)
{
    if (logger.isDebugEnabled() == true)
    {
        logger.debug("prepared started. taskIndex=" + context.getPartitionIndex()
                + ", taxkNum=" + context.numPartitions());
    }
}
 
Example 49
Project: acromusashi-stream-ml   File: ResultConsolePrinter.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void initialize(Map conf, TridentOperationContext context)
{
    // Do nothing.
}
 
Example 50
Project: acromusashi-stream-ml   File: DebugLogPrinter.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void initialize(Map conf, TridentOperationContext context)
{
    // Do nothing.
}
 
Example 51
Project: acromusashi-stream-ml   File: ResultLogPrinter.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void initialize(Map conf, TridentOperationContext context)
{
    // Do nothing.
}
 
Example 52
Project: acromusashi-stream-ml   File: ResultFilePrinter.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@SuppressWarnings("rawtypes")
@Override
public void initialize(Map conf, TridentOperationContext context)
{
    try
    {
        this.outputStream = new FileOutputStream(this.filePath, true);
    }
    catch (IOException ex)
    {
        throw new RuntimeException(ex);
    }
}
 
Example 53
Project: tfidf-topology   File: TermFilter.java   Source Code and License 5 votes vote down vote up
public void prepare(Map conf, TridentOperationContext context){
    super.prepare(conf, context);
    File dir = new File(System.getProperty("user.home") + "/dictionaries");
    Directory directory;
    try {
        directory = FSDirectory.open(dir);
        spellchecker = new SpellChecker(directory);
        StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_36);
        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_36, analyzer);
        URL dictionaryFile = TermFilter.class.getResource("/dictionaries/fulldictionary00.txt");
        spellchecker.indexDictionary(new PlainTextDictionary(new File(dictionaryFile.toURI())), config, true);
    } catch (Exception e) {
        LOG.error(e.toString());
    }
}
 
Example 54
Project: openbus   File: ElasticSearchIndexer.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(java.util.Map conf, TridentOperationContext context) {

    //instantiate ES Transport Client:
    Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", clusterName).build();
    TransportClient transportClient = new TransportClient(settings);
    for (String esNode : esNodes) {
        String[] hostAndPort = esNode.split(":");
        transportClient.addTransportAddress(new InetSocketTransportAddress(hostAndPort[0], Integer.parseInt(hostAndPort[1])));
    }
    client = transportClient;
}
 
Example 55
Project: first-stories-twitter   File: RecentTweetsStateQuery.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
	partitionNum = context.getPartitionIndex();
	numPartitions = context.numPartitions();
	myturn = partitionNum;
	threshold = Double.valueOf((String) conf.get("THRESHOLD"));
}
 
Example 56
Project: first-stories-twitter   File: VectorBuilder.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TridentOperationContext context) {
	int hashMapCapacity=Integer.valueOf((String) conf.get("UNIQUE_WORDS_EXPECTED"));
   	uniqWords = new HashMap<String, Integer>(hashMapCapacity);
       positionMap = new HashMap<String, Integer>(hashMapCapacity);
       idfMap = new HashMap<String, Double>(hashMapCapacity);

       tb = new TweetBuilder((String) conf.get("PATH_TO_OOV_FILE"));
}
 
Example 57
Project: jstorm   File: ChainedAggregatorImpl.java   Source Code and License 5 votes vote down vote up
public void prepare(Map conf, TridentOperationContext context) {
    _inputFactories = new ProjectionFactory[_inputFields.length];
    for (int i = 0; i < _inputFields.length; i++) {
        _inputFactories[i] = context.makeProjectionFactory(_inputFields[i]);
        _aggs[i].prepare(conf, new TridentOperationContext(context, _inputFactories[i]));
    }
}
 
Example 58
Project: jstorm   File: AggregateProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("Aggregate operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new FreshCollector(tridentContext);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _agg.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 59
Project: jstorm   File: MapProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<TridentTuple.Factory> parents = tridentContext.getParentTupleFactories();
    if(parents.size()!=1) {
        throw new RuntimeException("Map operation can only have one parent");
    }
    _context = tridentContext;
    _collector = new FreshCollector(tridentContext);
    _projection = new TridentTupleView.ProjectionFactory(parents.get(0), _inputFields);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}
 
Example 60
Project: jstorm   File: StateQueryProcessor.java   Source Code and License 5 votes vote down vote up
@Override
public void prepare(Map conf, TopologyContext context, TridentContext tridentContext) {
    List<Factory> parents = tridentContext.getParentTupleFactories();
    if (parents.size() != 1) {
        throw new RuntimeException("State query operation can only have one parent");
    }
    _context = tridentContext;
    _state = (State) context.getTaskData(_stateId);
    _projection = new ProjectionFactory(parents.get(0), _inputFields);
    _collector = new AppendCollector(tridentContext);
    _function.prepare(conf, new TridentOperationContext(context, _projection));
}