org.apache.samza.task.TaskContext Java Examples

The following examples show how to use org.apache.samza.task.TaskContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SamzaEntranceProcessingItem.java    From incubator-samoa with Apache License 2.0 6 votes vote down vote up
@Override
public void init(Config config, TaskContext context) throws Exception {
  String yarnConfHome = config.get(SamzaConfigFactory.YARN_CONF_HOME_KEY);
  if (yarnConfHome != null && yarnConfHome.length() > 0) // if the property is set, otherwise, assume we are running in local mode and ignore this
    SystemsUtils.setHadoopConfigHome(yarnConfHome);

  String filename = config.get(SamzaConfigFactory.FILE_KEY);
  String filesystem = config.get(SamzaConfigFactory.FILESYSTEM_KEY);

  this.setName(config.get(SamzaConfigFactory.JOB_NAME_KEY));
  SerializationProxy wrapper = (SerializationProxy) SystemsUtils.deserializeObjectFromFileAndKey(filesystem,
      filename, this.getName());
  this.setOutputStream(wrapper.outputStream);
  SamzaStream output = (SamzaStream) this.getOutputStream();
  if (output != null) // if output stream exists, set it up
    output.onCreate();
}
 
Example #2
Source File: SamzaProcessingItem.java    From incubator-samoa with Apache License 2.0 6 votes vote down vote up
@Override
public void init(Config config, TaskContext context) throws Exception {
  String yarnConfHome = config.get(SamzaConfigFactory.YARN_CONF_HOME_KEY);
  if (yarnConfHome != null && yarnConfHome.length() > 0) // if the property is set, otherwise, assume we are running in local mode and ignore this                                                            // set , otherwise,
    SystemsUtils.setHadoopConfigHome(yarnConfHome);

  String filename = config.get(SamzaConfigFactory.FILE_KEY);
  String filesystem = config.get(SamzaConfigFactory.FILESYSTEM_KEY);
  this.setName(config.get(SamzaConfigFactory.JOB_NAME_KEY));
  SerializationProxy wrapper = (SerializationProxy) SystemsUtils.deserializeObjectFromFileAndKey(filesystem,
      filename, this.getName());
  this.setProcessor(wrapper.processor);
  this.outputStreams = wrapper.outputStreams;

  // Init Processor and Streams
  this.getProcessor().onCreate(0);
  for (SamzaStream stream : this.outputStreams) {
    stream.onCreate();
  }

}
 
Example #3
Source File: SamzaEntranceProcessingItem.java    From samoa with Apache License 2.0 6 votes vote down vote up
@Override
public void init(Config config, TaskContext context) throws Exception {
	String yarnConfHome = config.get(SamzaConfigFactory.YARN_CONF_HOME_KEY);
	if (yarnConfHome != null && yarnConfHome.length() > 0) // if the property is set , otherwise, assume we are running in
           												// local mode and ignore this
		SystemsUtils.setHadoopConfigHome(yarnConfHome);
	
	String filename = config.get(SamzaConfigFactory.FILE_KEY);
	String filesystem = config.get(SamzaConfigFactory.FILESYSTEM_KEY);
	
	this.setName(config.get(SamzaConfigFactory.JOB_NAME_KEY));
	SerializationProxy wrapper = (SerializationProxy) SystemsUtils.deserializeObjectFromFileAndKey(filesystem, filename, this.getName());
	this.setOutputStream(wrapper.outputStream);
	SamzaStream output = (SamzaStream)this.getOutputStream();
	if (output != null) // if output stream exists, set it up
		output.onCreate();
}
 
Example #4
Source File: SamzaProcessingItem.java    From samoa with Apache License 2.0 6 votes vote down vote up
@Override
public void init(Config config, TaskContext context) throws Exception {
	String yarnConfHome = config.get(SamzaConfigFactory.YARN_CONF_HOME_KEY);
	if (yarnConfHome != null && yarnConfHome.length() > 0) // if the property is set , otherwise, assume we are running in
           													// local mode and ignore this
		SystemsUtils.setHadoopConfigHome(yarnConfHome);
	
	String filename = config.get(SamzaConfigFactory.FILE_KEY);
	String filesystem = config.get(SamzaConfigFactory.FILESYSTEM_KEY);
	this.setName(config.get(SamzaConfigFactory.JOB_NAME_KEY));
	SerializationProxy wrapper = (SerializationProxy) SystemsUtils.deserializeObjectFromFileAndKey(filesystem, filename, this.getName());
	this.setProcessor(wrapper.processor);
	this.outputStreams = wrapper.outputStreams;
	
	// Init Processor and Streams
	this.getProcessor().onCreate(0);
	for (SamzaStream stream:this.outputStreams) {
		stream.onCreate();
	}
	
}
 
Example #5
Source File: AbandonedCartStreamTask.java    From Unified-Log-Processing with Apache License 2.0 4 votes vote down vote up
public void init(Config config, TaskContext context) {
  this.store = (KeyValueStore<String, String>)
    context.getStore("nile-carts");
}
 
Example #6
Source File: HomeTimelineTask.java    From newsfeed with MIT License 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void init(Config config, TaskContext context) throws Exception {
  homeTimeline = (KeyValueStore<String, Map<String, Object>>) context.getStore("home-timeline");
}
 
Example #7
Source File: FanOutTask.java    From newsfeed with MIT License 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void init(Config config, TaskContext context) throws Exception {
  socialGraph = (KeyValueStore<String, String>) context.getStore("social-graph");
  userTimeline = (KeyValueStore<String, Map<String, Object>>) context.getStore("user-timeline");
}