org.apache.storm.utils.Utils.javaSerialize()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中org.apache.storm.utils.Utils.javaSerialize()方法的一些代码示例,展示了Utils.javaSerialize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.javaSerialize()方法的具体详情如下:
包路径:org.apache.storm.utils.Utils
类名称:Utils
方法名:javaSerialize

Utils.javaSerialize介绍

暂无

代码示例

代码示例来源:origin: apache/storm

public BatchBoltExecutor(IBatchBolt bolt) {
  _boltSer = Utils.javaSerialize(bolt);
}

代码示例来源:origin: apache/storm

/**
 * Add a new worker lifecycle hook
 *
 * @param workerHook the lifecycle hook to add
 */
public void addWorkerHook(IWorkerHook workerHook) {
  if (null == workerHook) {
    throw new IllegalArgumentException("WorkerHook must not be null.");
  }
  _workerHooks.add(ByteBuffer.wrap(Utils.javaSerialize(workerHook)));
}

代码示例来源:origin: apache/storm

public static Grouping prepareCustomStreamGrouping(Object obj) {
  return Grouping.custom_serialized(Utils.javaSerialize(obj));
}

代码示例来源:origin: apache/storm

public static ComponentObject serializeComponentObject(Object obj) {
  return ComponentObject.serialized_java(Utils.javaSerialize(obj));
}

代码示例来源:origin: apache/storm

private void setUpNimbusInfo(List<ACL> acls) {
  String leaderInfoPath = conf.get(Config.STORM_ZOOKEEPER_ROOT) + ClusterUtils.LEADERINFO_SUBTREE;
  NimbusInfo nimbusInfo = NimbusInfo.fromConf(conf);
  if (ClientZookeeper.existsNode(zk, leaderInfoPath, false)) {
    ClientZookeeper.setData(zk, leaderInfoPath, Utils.javaSerialize(nimbusInfo));
  } else {
    ClientZookeeper.createNode(zk, leaderInfoPath, Utils.javaSerialize(nimbusInfo), CreateMode.PERSISTENT, acls);
  }
}

代码示例来源:origin: apache/storm

/**
 * ## Repartitioning Operation
 *
 * @param partitioner
 * @return
 */
public Stream partition(CustomStreamGrouping partitioner) {
  return partition(Grouping.custom_serialized(Utils.javaSerialize(partitioner)));
}

代码示例来源:origin: apache/storm

@Override
public BoltDeclarer customGrouping(String componentId, String streamId, CustomStreamGrouping grouping) {
  return grouping(componentId, streamId, Grouping.custom_serialized(Utils.javaSerialize(grouping)));
}

代码示例来源:origin: apache/storm

public static SpoutSpec prepareSerializedSpoutDetails(IRichSpout spout, Map<String, StreamInfo> outputs) {
  return new SpoutSpec(ComponentObject.serialized_java
    (Utils.javaSerialize(spout)), prepareComponentCommon(new HashMap<>(), outputs, null, null));
}

代码示例来源:origin: apache/storm

public static Bolt prepareSerializedBoltDetails(Map<GlobalStreamId, Grouping> inputs, IBolt bolt, Map<String, StreamInfo> outputs,
                        Integer parallelismHint, Map<String, Object> conf) {
  ComponentCommon common = prepareComponentCommon(inputs, outputs, parallelismHint, conf);
  return new Bolt(ComponentObject.serialized_java(Utils.javaSerialize(bolt)), common);
}

代码示例来源:origin: apache/storm

@Test
public void classIsSerializable() throws Exception {
  Utils.javaSerialize(targetSelector);
}

代码示例来源:origin: apache/storm

try {
  maybeAddCheckpointInputs(common);
  boltSpecs.put(boltId, new Bolt(ComponentObject.serialized_java(Utils.javaSerialize(bolt)), common));
} catch (RuntimeException wrapperCause) {
  if (wrapperCause.getCause() != null && NotSerializableException.class.equals(wrapperCause.getCause().getClass())) {
ComponentCommon common = getComponentCommon(spoutId, spout);
try {
  spoutSpecs.put(spoutId, new SpoutSpec(ComponentObject.serialized_java(Utils.javaSerialize(spout)), common));
} catch (RuntimeException wrapperCause) {
  if (wrapperCause.getCause() != null && NotSerializableException.class.equals(wrapperCause.getCause().getClass())) {

代码示例来源:origin: apache/storm

private static PartitionNode makeIdentityPartition(Node basis) {
  return new PartitionNode(basis.streamId, basis.name, basis.allOutputFields,
               Grouping.custom_serialized(Utils.javaSerialize(new IdentityGrouping())));
}

代码示例来源:origin: apache/storm

@Test
public void classIsSerializable() throws Exception {
  PartialKeyGrouping.AssignmentCreator assignmentCreator = new PartialKeyGrouping.RandomTwoTaskAssignmentCreator();
  Utils.javaSerialize(assignmentCreator);
}

代码示例来源:origin: apache/storm

@Test
public void testGroupingIsSerializable() throws Exception {
  PartialKeyGrouping grouping = new PartialKeyGrouping(new Fields("some_field"));
  Utils.javaSerialize(grouping);
}

代码示例来源:origin: apache/storm

private StormTopology genereateStormTopology(boolean withWorkerHook) {
    ImmutableMap<String, SpoutSpec> spouts = ImmutableMap.of("spout-1", new SpoutSpec());
    ImmutableMap<String, Bolt> bolts = ImmutableMap.of("bolt-1", new Bolt());
    ImmutableMap<String, StateSpoutSpec> state_spouts = ImmutableMap.of();

    StormTopology stormTopology = new StormTopology(spouts, bolts, state_spouts);

    if (withWorkerHook) {
      BaseWorkerHook workerHook = new BaseWorkerHook();
      stormTopology.add_to_worker_hooks(ByteBuffer.wrap(Utils.javaSerialize(workerHook)));
    }

    return stormTopology;
  }
}

代码示例来源:origin: apache/storm

@Test
public void testServerExistsTrue() {
  String path = "/exists_path";
  String dataString = "pulse data";
  HBPulse hbPulse = new HBPulse();
  hbPulse.set_id(path);
  hbPulse.set_details(Utils.javaSerialize(dataString));
  messageWithRandId(HBServerMessageType.SEND_PULSE, HBMessageData.pulse(hbPulse));
  handler.handleMessage(hbMessage, true);
  messageWithRandId(HBServerMessageType.EXISTS, HBMessageData.path(path));
  HBMessage badResponse = handler.handleMessage(hbMessage, false);
  HBMessage goodResponse = handler.handleMessage(hbMessage, true);
  Assert.assertEquals(mid, badResponse.get_message_id());
  Assert.assertEquals(HBServerMessageType.NOT_AUTHORIZED, badResponse.get_type());
  Assert.assertEquals(mid, goodResponse.get_message_id());
  Assert.assertEquals(HBServerMessageType.EXISTS_RESPONSE, goodResponse.get_type());
  Assert.assertTrue(goodResponse.get_data().get_boolval());
}

代码示例来源:origin: org.apache.storm/storm-core

/**
 * Add a new worker lifecycle hook
 *
 * @param workerHook the lifecycle hook to add
 */
public void addWorkerHook(IWorkerHook workerHook) {
  if(null == workerHook) {
    throw new IllegalArgumentException("WorkerHook must not be null.");
  }
  _workerHooks.add(ByteBuffer.wrap(Utils.javaSerialize(workerHook)));
}

代码示例来源:origin: org.apache.storm/storm-core

/**
 * ## Repartitioning Operation
 *
 * @param partitioner
 * @return
 */
public Stream partition(CustomStreamGrouping partitioner) {
  return partition(Grouping.custom_serialized(Utils.javaSerialize(partitioner)));
}

代码示例来源:origin: org.apache.storm/storm-core

@Override
public BoltDeclarer customGrouping(String componentId, String streamId, CustomStreamGrouping grouping) {
  return grouping(componentId, streamId, Grouping.custom_serialized(Utils.javaSerialize(grouping)));
}

代码示例来源:origin: org.apache.storm/storm-core

private static PartitionNode makeIdentityPartition(Node basis) {
  return new PartitionNode(basis.streamId, basis.name, basis.allOutputFields,
    Grouping.custom_serialized(Utils.javaSerialize(new IdentityGrouping())));
}

相关文章

Utils类方法