Java源码示例:org.apache.mina.core.future.IoFuture

示例1
@Override
public void operationComplete(IoFuture future) {
    if (future.isDone()) {
        if (logger.isInfoEnabled()) {
            logger.info("[JobX] MinaRPC sent success, request id:{}", rpcFuture.getRequest().getId());
        }
        return;
    } else {
        if (logger.isInfoEnabled()) {
            logger.info("[JobX] MinaRPC sent failure, request id:{}", rpcFuture.getRequest().getId());
        }
        if (rpcFuture != null) {
            rpcFuture.caught(getConnect(rpcFuture.getRequest()).getException());
        }
    }
    futureTable.remove(rpcFuture.getRequest().getId());
}
 
示例2
public static boolean awaitUninterruptibly(Iterable<? extends IoFuture> futures, long timeoutMillis) {
    try {
        return await0(futures, timeoutMillis, false);
    } catch (InterruptedException e) {
        throw new InternalError();
    }
}
 
示例3
private static boolean await0(Iterable<? extends IoFuture> futures, long timeoutMillis, boolean interruptable)
        throws InterruptedException {
    long startTime = timeoutMillis <= 0 ? 0 : System.currentTimeMillis();
    long waitTime = timeoutMillis;

    boolean lastComplete = true;
    Iterator<? extends IoFuture> i = futures.iterator();
    while (i.hasNext()) {
        IoFuture f = i.next();
        do {
            if (interruptable) {
                lastComplete = f.await(waitTime);
            } else {
                lastComplete = f.awaitUninterruptibly(waitTime);
            }

            waitTime = timeoutMillis - (System.currentTimeMillis() - startTime);

            if (lastComplete || waitTime <= 0) {
                break;
            }
        } while (!lastComplete);

        if (waitTime <= 0) {
            break;
        }
    }

    return lastComplete && !i.hasNext();
}
 
示例4
/**
 * Close all the sessions
 * TODO disconnectSessions.
 *
 */
private void disconnectSessions() {
    if (!(service instanceof IoAcceptor)) {
        // We don't disconnect sessions for anything but an Acceptor
        return;
    }

    if (!((IoAcceptor) service).isCloseOnDeactivation()) {
        return;
    }

    Object lock = new Object();
    IoFutureListener<IoFuture> listener = new LockNotifyingListener(lock);

    for (IoSession s : managedSessions.values()) {
        s.close(true).addListener(listener);
    }

    try {
        synchronized (lock) {
            while (!managedSessions.isEmpty()) {
                lock.wait(500);
            }
        }
    } catch (InterruptedException ie) {
        // Ignored
    }
}
 
示例5
public void operationComplete(IoFuture future) {
    synchronized (TAKEN_LOCAL_ADDRESSES) {
        TAKEN_LOCAL_ADDRESSES.remove(future.getSession().getLocalAddress());
    }
}
 
示例6
void doFinishSessionInitialization(IoSession session, IoFuture future) {
    initSession(session, future, null);
}
 
示例7
public static void await(Iterable<? extends IoFuture> futures) throws InterruptedException {
    for (IoFuture f : futures) {
        f.await();
    }
}
 
示例8
public static void awaitUninterruptably(Iterable<? extends IoFuture> futures) {
    for (IoFuture f : futures) {
        f.awaitUninterruptibly();
    }
}
 
示例9
public static boolean await(Iterable<? extends IoFuture> futures, long timeout, TimeUnit unit)
        throws InterruptedException {
    return await(futures, unit.toMillis(timeout));
}
 
示例10
public static boolean await(Iterable<? extends IoFuture> futures, long timeoutMillis) throws InterruptedException {
    return await0(futures, timeoutMillis, true);
}
 
示例11
public static boolean awaitUninterruptibly(Iterable<? extends IoFuture> futures, long timeout, TimeUnit unit) {
    return awaitUninterruptibly(futures, unit.toMillis(timeout));
}
 
示例12
public void operationComplete(IoFuture future) {
    removeSession((AbstractIoSession) future.getSession());
}
 
示例13
public void operationComplete(IoFuture future) {
    synchronized (lock) {
        lock.notifyAll();
    }
}
 
示例14
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().aiMessageSent++;
}
 
示例15
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().aiMessageSent++;
}
 
示例16
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().aiMessageSent++;
}
 
示例17
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().messageClientSent++;
}
 
示例18
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().messageClientSent++;
}
 
示例19
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().rpcClientSent++;
}
 
示例20
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().rpcClientSent++;
}
 
示例21
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().gameClientSent++;
}
 
示例22
@Override
public IoFutureListener<IoFuture> getStatListener() {
	return statListener;
}
 
示例23
@Override
public void setStatListener(IoFutureListener<IoFuture> statListener) {
	this.statListener = statListener;
}
 
示例24
@Override
public IoFutureListener<IoFuture> getStatListener() {
	return statListener;
}
 
示例25
@Override
public void setStatListener(IoFutureListener<IoFuture> statListener) {
	this.statListener = statListener;
}
 
示例26
/**
 * Implement this method to perform additional tasks required for session
 * initialization. Do not call this method directly;
 * {@link #initSession(IoSession, IoFuture, IoSessionInitializer)} will call
 * this method instead.
 */
protected void finishSessionInitialization0(IoSession session, IoFuture future) {
    // Do nothing. Extended class might add some specific code 
}
 
示例27
/**
 * @return the statListener
 */
public abstract IoFutureListener<IoFuture> getStatListener();
 
示例28
/**
 * @param statListener the statListener to set
 */
public abstract void setStatListener(IoFutureListener<IoFuture> statListener);