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

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

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

Utils.wrapInRuntime介绍

暂无

代码示例

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

@Override
public void close() {
  if (logviewerCleanupTimer != null) {
    try {
      logviewerCleanupTimer.close();
    } catch (Exception ex) {
      throw Utils.wrapInRuntime(ex);
    }
  }
}

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

public static String errorPath(String stormId, String componentId) {
  try {
    return errorStormRoot(stormId) + ZK_SEPERATOR + URLEncoder.encode(componentId, "UTF-8");
  } catch (UnsupportedEncodingException e) {
    throw Utils.wrapInRuntime(e);
  }
}

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

@Override
  public IStateStorage mkStore(Map<String, Object> config, Map<String, Object> auth_conf, ClusterStateContext context) {
    try {
      return new ZKStateStorage(config, auth_conf, context);
    } catch (Exception e) {
      throw Utils.wrapInRuntime(e);
    }
  }
}

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

private Runnable sleep() {
  return () -> {
    try {
      Thread.sleep(10);
    } catch (InterruptedException e) {
      throw Utils.wrapInRuntime(e);
    }
  };
}

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

@Override
public NimbusInfo getLeader() {
  try {
    return Zookeeper.toNimbusInfo(leaderLatch.get().getLeader());
  } catch (Exception e) {
    throw Utils.wrapInRuntime(e);
  }
}

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

public void refreshConnections() {
  try {
    refreshConnections(() -> refreshConnectionsTimer.schedule(0, this::refreshConnections));
  } catch (Exception e) {
    throw Utils.wrapInRuntime(e);
  }
}

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

@Override
  public void report(Throwable error) {
    LOG.error("Error", error);
    if (Time.deltaSecs(intervalStartTime.get()) > errorIntervalSecs) {
      intervalErrors.set(0);
      intervalStartTime.set(Time.currentTimeSecs());
    }
    if (intervalErrors.incrementAndGet() <= maxPerInterval) {
      try {
        stormClusterState.reportError(stormId, componentId, Utils.hostname(),
                       workerTopologyContext.getThisWorkerPort().longValue(), error);
      } catch (UnknownHostException e) {
        throw Utils.wrapInRuntime(e);
      }

    }
  }
}

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

public static Stat setData(CuratorFramework zk, String path, byte[] data) {
  try {
    String npath = normalizePath(path);
    return zk.setData().forPath(npath, data);
  } catch (Exception e) {
    throw Utils.wrapInRuntime(e);
  }
}

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

public static void syncPath(CuratorFramework zk, String path) {
  try {
    zk.sync().forPath(normalizePath(path));
  } catch (Exception e) {
    throw Utils.wrapInRuntime(e);
  }
}

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

public WorkerTopologyContext getWorkerTopologyContext() {
  try {
    String codeDir = ConfigUtils.supervisorStormResourcesPath(ConfigUtils.supervisorStormDistRoot(conf, topologyId));
    String pidDir = ConfigUtils.workerPidsRoot(conf, topologyId);
    return new WorkerTopologyContext(systemTopology, topologyConf, taskToComponent, componentToSortedTasks,
                     componentToStreamToFields, topologyId, codeDir, pidDir, port, localTaskIds,
                     defaultSharedResources,
                     userSharedResources, cachedTaskToNodePort, assignmentId);
  } catch (IOException e) {
    throw Utils.wrapInRuntime(e);
  }
}

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

public static Executor mkExecutor(WorkerState workerState, List<Long> executorId, Map<String, String> credentials) {
  Executor executor;
  WorkerTopologyContext workerTopologyContext = workerState.getWorkerTopologyContext();
  List<Integer> taskIds = StormCommon.executorIdToTasks(executorId);
  String componentId = workerTopologyContext.getComponentId(taskIds.get(0));
  String type = getExecutorType(workerTopologyContext, componentId);
  if (ClientStatsUtil.SPOUT.equals(type)) {
    executor = new SpoutExecutor(workerState, executorId, credentials);
  } else {
    executor = new BoltExecutor(workerState, executorId, credentials);
  }
  int minId = Integer.MAX_VALUE;
  Map<Integer, Task> idToTask = new HashMap<>();
  for (Integer taskId : taskIds) {
    minId = Math.min(minId, taskId);
    try {
      Task task = new Task(executor, taskId);
      idToTask.put(taskId, task);
    } catch (IOException ex) {
      throw Utils.wrapInRuntime(ex);
    }
  }
  executor.idToTaskBase = minId;
  executor.idToTask = Utils.convertToArray(idToTask, minId);
  return executor;
}

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

@Override
  public IStateStorage mkStore(Map<String, Object> config, Map<String, Object> auth_conf, ClusterStateContext context) {
    try {
      ZKStateStorageFactory zkfact = new ZKStateStorageFactory();
      IStateStorage zkState = zkfact.mkStore(config, auth_conf, context);
      return new PaceMakerStateStorage(new PacemakerClientPool(config), zkState);
    } catch (Exception e) {
      throw Utils.wrapInRuntime(e);
    }
  }
}

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

public static void deleteNode(CuratorFramework zk, String path) {
  try {
    String npath = normalizePath(path);
    if (existsNode(zk, npath, false)) {
      zk.delete().deletingChildrenIfNeeded().forPath(normalizePath(path));
    }
  } catch (Exception e) {
    if (Utils.exceptionCauseIsInstanceOf(KeeperException.NodeExistsException.class, e)) {
      // do nothing
      LOG.info("delete {} failed.", path, e);
    } else {
      throw Utils.wrapInRuntime(e);
    }
  }
}

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

public static String createNode(CuratorFramework zk, String path, byte[] data, CreateMode mode, List<ACL> acls) {
  String ret = null;
  try {
    String npath = normalizePath(path);
    ret = zk.create().creatingParentsIfNeeded().withMode(mode).withACL(acls).forPath(npath, data);
  } catch (Exception e) {
    throw Utils.wrapInRuntime(e);
  }
  return ret;
}

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

public static List<String> getChildren(CuratorFramework zk, String path, boolean watch) {
  try {
    String npath = normalizePath(path);
    if (watch) {
      return zk.getChildren().watched().forPath(npath);
    } else {
      return zk.getChildren().forPath(npath);
    }
  } catch (Exception e) {
    throw Utils.wrapInRuntime(e);
  }
}

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

public static boolean existsNode(CuratorFramework zk, String path, boolean watch) {
  Stat stat = null;
  try {
    if (watch) {
      stat = zk.checkExists().watched().forPath(normalizePath(path));
    } else {
      stat = zk.checkExists().forPath(normalizePath(path));
    }
  } catch (Exception e) {
    throw Utils.wrapInRuntime(e);
  }
  return stat != null;
}

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

public static byte[] getData(CuratorFramework zk, String path, boolean watch) {
  try {
    String npath = normalizePath(path);
    if (existsNode(zk, npath, watch)) {
      if (watch) {
        return zk.getData().watched().forPath(npath);
      } else {
        return zk.getData().forPath(npath);
      }
    }
  } catch (Exception e) {
    if (Utils.exceptionCauseIsInstanceOf(KeeperException.NoNodeException.class, e)) {
      // this is fine b/c we still have a watch from the successful exists call
    } else {
      throw Utils.wrapInRuntime(e);
    }
  }
  return null;
}

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

public void shutdownAllWorkers(UniFunc<Slot> onWarnTimeout, UniFunc<Slot> onErrorTimeout) {
  if (readState != null) {
    readState.shutdownAllWorkers(onWarnTimeout, onErrorTimeout);
  } else {
    try {
      ContainerLauncher launcher = ContainerLauncher.make(getConf(), getId(), getThriftServerPort(),
                                getSharedContext(), getMetricsRegistry(), getContainerMemoryTracker());
      killWorkers(SupervisorUtils.supervisorWorkerIds(conf), launcher);
    } catch (Exception e) {
      throw Utils.wrapInRuntime(e);
    }
  }
}

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

public void ackSpoutMsg(SpoutExecutor executor, Task taskData, Long timeDelta, TupleInfo tupleInfo) {
  try {
    ISpout spout = (ISpout) taskData.getTaskObject();
    int taskId = taskData.getTaskId();
    if (executor.getIsDebug()) {
      LOG.info("SPOUT Acking message {} {}", tupleInfo.getId(), tupleInfo.getMessageId());
    }
    spout.ack(tupleInfo.getMessageId());
    if (!taskData.getUserContext().getHooks().isEmpty()) { // avoid allocating SpoutAckInfo obj if not necessary
      new SpoutAckInfo(tupleInfo.getMessageId(), taskId, timeDelta).applyOn(taskData.getUserContext());
    }
    if (hasAckers && timeDelta != null) {
      executor.getStats().spoutAckedTuple(tupleInfo.getStream(), timeDelta,
                        taskData.getTaskMetrics().getAcked(tupleInfo.getStream()));
    }
  } catch (Exception e) {
    throw Utils.wrapInRuntime(e);
  }
}

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

public void failSpoutMsg(SpoutExecutor executor, Task taskData, Long timeDelta, TupleInfo tupleInfo, String reason) {
  try {
    ISpout spout = (ISpout) taskData.getTaskObject();
    int taskId = taskData.getTaskId();
    if (executor.getIsDebug()) {
      LOG.info("SPOUT Failing {} : {} REASON: {}", tupleInfo.getId(), tupleInfo, reason);
    }
    spout.fail(tupleInfo.getMessageId());
    new SpoutFailInfo(tupleInfo.getMessageId(), taskId, timeDelta).applyOn(taskData.getUserContext());
    if (timeDelta != null) {
      executor.getStats().spoutFailedTuple(tupleInfo.getStream(), timeDelta,
                         taskData.getTaskMetrics().getFailed(tupleInfo.getStream()));
    }
  } catch (Exception e) {
    throw Utils.wrapInRuntime(e);
  }
}

相关文章

Utils类方法