backtype.storm.utils.Utils.exceptionCauseIsInstanceOf()方法的使用及代码示例

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

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

Utils.exceptionCauseIsInstanceOf介绍

暂无

代码示例

代码示例来源:origin: alibaba/jstorm

public void cleanupBefore(long txid) {
  SortedMap<Long, Object> toDelete = _curr.headMap(txid);
  for(long tx: new HashSet<>(toDelete.keySet())) {
    _curr.remove(tx);
    try {
      _state.delete(txPath(tx));
    } catch(RuntimeException e) {
      // Ignore NoNodeExists exceptions because when sync() it may populate _curr with stale data since
      // zookeeper reads are eventually consistent.
      if(!Utils.exceptionCauseIsInstanceOf(KeeperException.NoNodeException.class, e)) {
        throw e;
      }
    }
  }
}

代码示例来源:origin: alibaba/jstorm

@SuppressWarnings("unused")
protected Object deserialize(byte[] serMsg, int taskId) {
  try {
    if (serMsg == null) {
      return null;
    }
    if (serMsg.length == 0) {
      return null;
    } else if (serMsg.length == 1) {
      //ignore
      return null;
    }
    Tuple tuple = null;
    // serMsg.length > 1
    KryoTupleDeserializer kryo = atomKryoDeserializer.get();
    if (kryo != null) {
      tuple = kryo.deserialize(serMsg);
    }
    return tuple;
  } catch (Throwable e) {
    if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e))
      throw new RuntimeException(e);
    LOG.error(idStr + " recv thread error " + JStormUtils.toPrintableString(serMsg) + "\n", e);
  }
  return null;
}

代码示例来源:origin: alibaba/jstorm

@Override
public void handleEvent(Object event, boolean endOfBatch) throws Exception {
  TaskMessage message = (TaskMessage) event;
  int task = message.task();
  Object tuple = null;
  try {
    //there might be errors when calling update_topology
    tuple = deserialize(message.message(), task);
  } catch (Throwable e) {
    if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e))
      throw new RuntimeException(e);
    LOG.warn("serialize msg error", e);
  }
  DisruptorQueue queue = controlQueues.get(task);
  if (queue == null) {
    LOG.warn("Received invalid control message for task-{}, Dropping...{} ", task, tuple);
    return;
  }
  if (tuple != null) {
    queue.publish(tuple);
  }
}

代码示例来源:origin: alibaba/jstorm

@Override
public void handleEvent(Object event, boolean endOfBatch) throws Exception {
  if (event == null) {
    return;
  }
  ITupleExt tuple = (ITupleExt) event;
  int targetTask = tuple.getTargetTaskId();
  IConnection conn = getConnection(targetTask);
  if (conn != null) {
    byte[] tupleMessage = null;
    try {
      //there might be errors when calling update_topology
      tupleMessage = serialize(tuple);
    } catch (Throwable e) {
      if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e)) {
        throw new RuntimeException(e);
      } else {
        LOG.warn("serialize happened errors!!!", e);
      }
    }
    TaskMessage message = new TaskMessage(TaskMessage.CONTROL_MESSAGE, targetTask, tupleMessage);
    conn.sendDirect(message);
  }
}

代码示例来源:origin: alibaba/jstorm

public boolean deserializer(KryoTupleDeserializer deserializer, boolean forceConsume) {
  //LOG.debug("start Deserializer of task, {}", taskId);
  boolean isIdling = true;
  DisruptorQueue exeQueue = innerTaskTransfer.get(taskId);
  if (!taskStatus.isShutdown()) {
    if ((deserializeQueue.population() > 0 && exeQueue.pctFull() < 1.0) || forceConsume) {
      try {
        List<Object> objects = deserializeQueue.retreiveAvailableBatch();
        for (Object object : objects) {
          deserialize(deserializer, (byte[]) object, exeQueue);
        }
        isIdling = false;
      } catch (InterruptedException e) {
        LOG.error("InterruptedException " + e.getCause());
        return true;
      } catch (TimeoutException e) {
        return true;
      } catch (Throwable e) {
        if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e)) {
          throw new RuntimeException(e);
        } else if (!taskStatus.isShutdown()) {
          LOG.error("Unknown exception ", e);
        }
      }
    }
  } else {
    task.unregisterDeserializeQueue();
  }
  return isIdling;
}

代码示例来源:origin: alibaba/jstorm

protected void deserialize(KryoTupleDeserializer deserializer, byte[] serMsg, DisruptorQueue queue) {
  long start = deserializeTimer.getTime();
  try {
    if (serMsg == null || serMsg.length == 0) {
      return;
    }
    if (serMsg.length == 1) {
      byte newStatus = serMsg[0];
      LOG.info("Change task status as " + newStatus);
      taskStatus.setStatus(newStatus);
      return;
    }
    // ser_msg.length > 1
    if (bolt != null && bolt instanceof IProtoBatchBolt) {
      ((IProtoBatchBolt) bolt).protoExecute(this, deserializer, queue, serMsg);
    } else {
      deserializeTuple(deserializer, serMsg, queue);
    }
  } catch (Throwable e) {
    if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e))
      throw new RuntimeException(e);
    if (!taskStatus.isShutdown()) {
      LOG.error(idStr + " recv thread error " + JStormUtils.toPrintableString(serMsg), e);
    }
  } finally {
    if (MetricUtils.metricAccurateCal)
      deserializeTimer.updateTime(start);
  }
}

代码示例来源:origin: com.n3twork.storm/storm-core

public void cleanupBefore(long txid) {
  SortedMap<Long, Object> toDelete = _curr.headMap(txid);
  for(long tx: new HashSet<Long>(toDelete.keySet())) {
    _curr.remove(tx);
    try {
      _state.delete(txPath(tx));
    } catch(RuntimeException e) {
      // Ignore NoNodeExists exceptions because when sync() it may populate _curr with stale data since
      // zookeeper reads are eventually consistent.
      if(!Utils.exceptionCauseIsInstanceOf(KeeperException.NoNodeException.class, e)) {
        throw e;
      }
    }
  }
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

public void cleanupBefore(long txid) {
  SortedMap<Long, Object> toDelete = _curr.headMap(txid);
  for(long tx: new HashSet<Long>(toDelete.keySet())) {
    _curr.remove(tx);
    try {
      _state.delete(txPath(tx));
    } catch(RuntimeException e) {
      // Ignore NoNodeExists exceptions because when sync() it may populate _curr with stale data since
      // zookeeper reads are eventually consistent.
      if(!Utils.exceptionCauseIsInstanceOf(KeeperException.NoNodeException.class, e)) {
        throw e;
      }
    }
  }
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

protected Object deserialize(byte[] ser_msg, int taskId) {
  try {
    if (ser_msg == null) {
      return null;
    }
    if (ser_msg.length == 0) {
      return null;
    } else if (ser_msg.length == 1) {
      //ignore
      return null;
    }
    Tuple tuple = null;
    // ser_msg.length > 1
    KryoTupleDeserializer kryo = atomKryoDeserializer.get();
    if (kryo != null)
      tuple = kryo.deserialize(ser_msg);
    return tuple;
  }  catch (Throwable e) {
    if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e))
      throw new RuntimeException(e);
    LOG.error(idStr + " recv thread error " + JStormUtils.toPrintableString(ser_msg) + "\n", e);
  }
  return null;
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

@Override
public void handleEvent(Object event, boolean endOfBatch) throws Exception {
  TaskMessage message = (TaskMessage) event;
  int task = message.task();
  Object tuple = null;
  try {
    //it maybe happened errors when update_topology
    tuple = deserialize(message.message(), task);
  }catch (Throwable e){
    if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e))
      throw new RuntimeException(e);
    LOG.warn("serialize happened errors!!! {}", e);
  }
  DisruptorQueue queue = controlQueues.get(task);
  if (queue == null) {
    LOG.warn("Received invalid control message form task-{}, Dropping...{} ", task, tuple);
    return;
  }
  if (tuple != null) {
    queue.publish(tuple);
  }
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

@Override
public void handleEvent(Object event, boolean endOfBatch) throws Exception {
  if (event == null) {
    return;
  }
  ITupleExt tuple = (ITupleExt) event;
  int targetTask = tuple.getTargetTaskId();
  IConnection conn = getConnection(targetTask);
  if (conn != null) {
    byte[] tupleMessage = null;
    try {
      //it maybe happened errors when update_topology
      tupleMessage = serialize(tuple);
    } catch (Throwable e) {
      if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e)) {
        throw new RuntimeException(e);
      } else {
        LOG.warn("serialize happened errors!!!", e);
      }
    }
    TaskMessage message = new TaskMessage((short) TaskMessage.CONTROL_MESSAGE, targetTask, tupleMessage);
    conn.send(message);
  }
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

public boolean deserializer(KryoTupleDeserializer deserializer, boolean forceConsume) {
  //LOG.debug("start Deserializer of task, {}", taskId);
  boolean isIdling = true;
  DisruptorQueue exeQueue = innerTaskTransfer.get(taskId);
  if (!taskStatus.isShutdown()) {
    if ((deserializeQueue.population() > 0 && exeQueue.pctFull() < 1.0) || forceConsume) {
      try {
        List<Object> objects = deserializeQueue.retreiveAvailableBatch();
        for (Object object : objects) {
          deserialize(deserializer, (byte[]) object, exeQueue);
        }
        isIdling = false;
      } catch (InterruptedException e) {
        LOG.error("InterruptedException " + e.getCause());
        return isIdling;
      } catch (TimeoutException e) {
        return isIdling;
      } catch (Throwable e) {
        if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e)) {
          throw new RuntimeException(e);
        } else if (!taskStatus.isShutdown()) {
          LOG.error("Unknow exception ", e);
        }
      }
    }
  } else {
    task.unregisterDeserializeQueue();
  }
  return isIdling;
}

代码示例来源:origin: com.alibaba.jstorm/jstorm-core

if (Utils.exceptionCauseIsInstanceOf(KryoException.class, e))
  throw new RuntimeException(e);
if (!taskStatus.isShutdown()) {

相关文章