org.apache.mina.core.future.IoFuture Java Examples

The following examples show how to use org.apache.mina.core.future.IoFuture. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractClient.java    From JobX with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #2
Source File: IoUtil.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean awaitUninterruptibly(Iterable<? extends IoFuture> futures, long timeoutMillis) {
    try {
        return await0(futures, timeoutMillis, false);
    } catch (InterruptedException e) {
        throw new InternalError();
    }
}
 
Example #3
Source File: IoUtil.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
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();
}
 
Example #4
Source File: IoServiceListenerSupport.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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
    }
}
 
Example #5
Source File: AIServerHandler.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().aiMessageSent++;
}
 
Example #6
Source File: ClientPool.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void setStatListener(IoFutureListener<IoFuture> statListener) {
	this.statListener = statListener;
}
 
Example #7
Source File: ClientPool.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public IoFutureListener<IoFuture> getStatListener() {
	return statListener;
}
 
Example #8
Source File: SimpleClient.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void setStatListener(IoFutureListener<IoFuture> statListener) {
	this.statListener = statListener;
}
 
Example #9
Source File: SimpleClient.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public IoFutureListener<IoFuture> getStatListener() {
	return statListener;
}
 
Example #10
Source File: GameProxyClient.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().gameClientSent++;
}
 
Example #11
Source File: MinaRpcPoolChannel.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().rpcClientSent++;
}
 
Example #12
Source File: MinaRpcChannel.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().rpcClientSent++;
}
 
Example #13
Source File: GameClient.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().messageClientSent++;
}
 
Example #14
Source File: MessageClient.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().messageClientSent++;
}
 
Example #15
Source File: AIClientHandler.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().aiMessageSent++;
}
 
Example #16
Source File: AIClient.java    From gameserver with Apache License 2.0 4 votes vote down vote up
@Override
public void operationComplete(IoFuture future) {
	Stat.getInstance().aiMessageSent++;
}
 
Example #17
Source File: VmPipeConnector.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public void operationComplete(IoFuture future) {
    synchronized (TAKEN_LOCAL_ADDRESSES) {
        TAKEN_LOCAL_ADDRESSES.remove(future.getSession().getLocalAddress());
    }
}
 
Example #18
Source File: IoServiceListenerSupport.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public void operationComplete(IoFuture future) {
    synchronized (lock) {
        lock.notifyAll();
    }
}
 
Example #19
Source File: IdleStatusChecker.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public void operationComplete(IoFuture future) {
    removeSession((AbstractIoSession) future.getSession());
}
 
Example #20
Source File: IoUtil.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean awaitUninterruptibly(Iterable<? extends IoFuture> futures, long timeout, TimeUnit unit) {
    return awaitUninterruptibly(futures, unit.toMillis(timeout));
}
 
Example #21
Source File: IoUtil.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean await(Iterable<? extends IoFuture> futures, long timeoutMillis) throws InterruptedException {
    return await0(futures, timeoutMillis, true);
}
 
Example #22
Source File: IoUtil.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public static boolean await(Iterable<? extends IoFuture> futures, long timeout, TimeUnit unit)
        throws InterruptedException {
    return await(futures, unit.toMillis(timeout));
}
 
Example #23
Source File: IoUtil.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public static void awaitUninterruptably(Iterable<? extends IoFuture> futures) {
    for (IoFuture f : futures) {
        f.awaitUninterruptibly();
    }
}
 
Example #24
Source File: IoUtil.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
public static void await(Iterable<? extends IoFuture> futures) throws InterruptedException {
    for (IoFuture f : futures) {
        f.await();
    }
}
 
Example #25
Source File: VmPipeAcceptor.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
void doFinishSessionInitialization(IoSession session, IoFuture future) {
    initSession(session, future, null);
}
 
Example #26
Source File: AbstractIoService.java    From neoscada with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * 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 
}
 
Example #27
Source File: Client.java    From gameserver with Apache License 2.0 2 votes vote down vote up
/**
 * @return the statListener
 */
public abstract IoFutureListener<IoFuture> getStatListener();
 
Example #28
Source File: Client.java    From gameserver with Apache License 2.0 2 votes vote down vote up
/**
 * @param statListener the statListener to set
 */
public abstract void setStatListener(IoFutureListener<IoFuture> statListener);