gpt4 book ai didi

org.zeromq.ZMQException类的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 03:44:49 30 4
gpt4 key购买 nike

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

ZMQException介绍

[英]ZeroMQ runtime exception.
[中]ZeroMQ运行时异常。

代码示例

代码示例来源:origin: zeromq/jzmq

/**
 * Bind to network interface to a random port. Start listening for new connections.
 * 
 * @param addr the endpoint to bind to.
 * @param min_port The minimum port in the range of ports to try.
 * @param max_port The maximum port in the range of ports to try.
 * @param max_tries The number of attempt to bind.
 */
public int bindToRandomPort(String addr, int min_port, int max_port, int max_tries) {
  int port;
  Random rand = new Random();
  for (int i = 0; i < max_tries; i++) {
    port = rand.nextInt(max_port - min_port + 1) + min_port;
    try {
      bind(String.format("%s:%s", addr, port));
      return port;
    } catch (ZMQException e) {
      if (e.getErrorCode() != ZMQ.EADDRINUSE()) {
        throw e;
      }
      continue;
    }
  }
  throw new ZMQException("Could not bind socket to random port.", (int) ZMQ.EADDRINUSE());
}

代码示例来源:origin: zeromq/jzmq

public ZMQException(ZMQException cause) {
  super(cause.getMessage(), cause);
  this.errorCode = cause.errorCode;
}

代码示例来源:origin: org.zeromq/jeromq

private void mayRaise()
{
  int errno = base.errno();
  if (errno != 0 && errno != zmq.ZError.EAGAIN) {
    throw new ZMQException(errno);
  }
}

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

if (e.getErrorCode() == ZMQ.Error.ETERM.getCode()) {
  break;

代码示例来源:origin: org.zeromq/jeromq

@Override
public void start(Socket pipe, List<Socket> sockets, ZPoller poller)
{
  boolean rc;
  try {
    rc = replies.bind(repliesAddress);
    assert (rc);
    Socket handler = sockets.get(0);
    rc = handler.bind("inproc://zeromq.zap.01");
    assert (rc);
    rc = poller.register(handler, ZPoller.POLLIN);
    assert (rc);
    rc = pipe.send(OK);
    assert (rc);
  }
  catch (ZMQException e) {
    System.out.println("ZAuth: Error");
    e.printStackTrace();
    rc = pipe.send("ERROR");
    assert (rc);
  }
}

代码示例来源:origin: fbacchella/LogHub

@Override
public boolean configure(Properties properties) {
  try {
    listeningSocket = ctx.newSocket(method, type, listen);
    listeningSocket.setImmediate(false);
    listeningSocket.setReceiveTimeOut(-1);
    listeningSocket.setHWM(hwm);
    if(type == Sockets.SUB){
      listeningSocket.subscribe(new byte[] {});
    }
    boolean configured = super.configure(properties);
    stopPair = ctx.getPair(getName() + "/" + UUID.randomUUID());
    return configured;
  } catch (org.zeromq.ZMQException e) {
    ZMQHelper.logZMQException(logger, "failed to start ZMQ input " + listen + ":", e);
    logger.catching(Level.DEBUG, e.getCause());
    listeningSocket = null;
    return false;
  }
}

代码示例来源:origin: org.zeromq/jeromq

private void mayRaise()
{
  final int errno = socketBase.errno();
  if (errno != 0 && errno != ZError.EAGAIN) {
    throw new ZMQException(errno);
  }
}

代码示例来源:origin: miniway/zper

@Override
public void run()
{
  LOG.info("Started Worker " + identity);
  worker = context.createSocket(ZMQ.DEALER);
  worker.setIdentity(identity.getBytes());
  worker.connect(bindAddr);
  try {
    loop();
  } catch (ZMQException e) {
    if (e.getErrorCode() != ZMQ.Error.ETERM.getCode())
      throw e;
  }
  context.destroy();
  LOG.info("Ended Reader Worker " + identity);
}

代码示例来源:origin: org.zeromq/jeromq

/**
 * Bind to network interface to a random port. Start listening for new
 * connections.
 *
 * @param addr
 *            the endpoint to bind to.
 * @param min
 *            The minimum port in the range of ports to try.
 * @param max
 *            The maximum port in the range of ports to try.
 */
public int bindToRandomPort(String addr, int min, int max)
{
  int port;
  Random rand = new Random();
  //            int port = min;
  //            while (port <= max) {
  for (int i = 0; i < 100; i++) { // hardcoded to 100 tries. should this be parametrised
    port = rand.nextInt(max - min + 1) + min;
    if (base.bind(String.format("%s:%s", addr, port))) {
      return port;
    }
    //                port++;
  }
  throw new ZMQException("Could not bind socket to random port.", ZError.EADDRINUSE);
}

代码示例来源:origin: miniway/zper

@Override
public void run()
{
  LOG.info("Started Worker " + identity);
  worker = context.createSocket(ZMQ.DEALER);
  worker.setRcvHWM(2000);
  worker.setIdentity(identity.getBytes());
  worker.connect(bindAddr);
  try {
    loop();
  } catch (ZMQException e) {
    if (e.getErrorCode() != ZMQ.Error.ETERM.getCode())
      throw e;
  }
  LOG.info("Ended Writer Worker " + identity);
  context.destroy();
}

代码示例来源:origin: tlrx/transport-zeromq

public ZMQRestResponse process(ZMQRestRequest request){
  
  final CountDownLatch latch = new CountDownLatch(1);
  final AtomicReference<ZMQRestResponse> ref = new AtomicReference<ZMQRestResponse>();
  
  this.restController.dispatchRequest(request, new RestChannel() {
    
    @Override
    public void sendResponse(RestResponse response) {
      try {
        if(logger.isTraceEnabled()){
          logger.info("Response to ØMQ client: {}", new String(response.content()));	
        }
        ref.set(convert(response));
      } catch (IOException e) {
        // ignore
      }
      latch.countDown();
    }
  });
  
  try {
    latch.await();
    return ref.get();
  } catch (Exception e) {
    throw new ZMQException("failed to generate response", 0);
  }
}

代码示例来源:origin: org.zeromq/jeromq

@Override
  public void run()
  {
    if (attachedRunnable != null) {
      try {
        attachedRunnable.run(args, ctx, pipe);
      }
      catch (ZMQException e) {
        if (e.getErrorCode() != Error.ETERM.getCode()) {
          throw e;
        }
      }
      ctx.destroy();
    }
    else {
      detachedRunnable.run(args);
    }
  }
}

代码示例来源:origin: org.zeromq/zeromq-scala-binding

private void raiseZMQException() {
 int errno = zmq.zmq_errno();
 String reason = zmq.zmq_strerror(errno);
 throw new ZMQException(reason, errno);
}

代码示例来源:origin: fbacchella/LogHub

public static void logZMQException(Logger l, String prefix, RuntimeException e) {
  ERRNO errno;
  Supplier<String> message;
  if (e instanceof ZError.IOException) {
    IOException cause = (java.io.IOException) e.getCause();
    errno = ERRNO.get(exccode(cause));
    message = () -> errno.toString(prefix, e);
  } else if (e instanceof ZError.CtxTerminatedException) {
    errno = ERRNO.ETERM;
    message = () -> errno.toString(prefix, e, new RuntimeException("Context terminated"));
  } else if (e instanceof ZError.InstantiationException) {
    errno = ERRNO.EOTHER;
    message =  () -> errno.toString(prefix, e, e.getCause());
  } else if (e instanceof ZMQException) {
    errno = ERRNO.get(((ZMQException)e).getErrorCode());
    message = () -> errno.toString(prefix, e);
  } else {
    throw e;
  }
  l.log(errno.level, message);
}

代码示例来源:origin: org.spark-project.zeromq/zeromq-scala-binding

private void raiseZMQException() {
 int errno = zmq.zmq_errno();
 String reason = zmq.zmq_strerror(errno);
 throw new ZMQException(reason, errno);
}

代码示例来源:origin: kawasima/enkan

if (e.getErrorCode() == ZError.ETERM) {
  break;

代码示例来源:origin: org.zeromq/zeromq-scala-binding_2.10

private void raiseZMQException() {
 int errno = zmq.zmq_errno();
 String reason = zmq.zmq_strerror(errno);
 throw new ZMQException(reason, errno);
}

代码示例来源:origin: org.spark-project.zeromq/zeromq-scala-binding_2.10

private void raiseZMQException() {
 int errno = zmq.zmq_errno();
 String reason = zmq.zmq_strerror(errno);
 throw new ZMQException(reason, errno);
}

代码示例来源:origin: stackoverflow.com

throw new ZMQException(errno);

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com