Examples of JxtaBiDiPipe


Examples of net.jxta.util.JxtaBiDiPipe

   
    /* return false if cannot send
     * else true
     */
    private boolean sendOverPipe(ReplicationState state, boolean isResponse) {
        JxtaBiDiPipe thePipe = null;
        boolean result = false;
        if(!ReplicationHealthChecker.isOkToProceed()) {
            return false;
        }
        String sourceInstanceName = state.getInstanceName();
        if(sourceInstanceName == null) {
            if (_pipelogger.isLoggable(Level.FINE)) {
                _pipelogger.fine("PROBLEM:sendOverPipe:isResponse=" + isResponse + " command=" + state.getCommand());
            }
            return false;
        }
        PipeWrapper thePipeWrapper = null;
        try {
            thePipeWrapper = this.getPipeWrapper(sourceInstanceName);
            if(thePipeWrapper == null) {
                return false;
            }
            thePipe = thePipeWrapper.getPipe();
            if(thePipe == null) {
                //no pipe to return to pool - just return
                return false;
            }

            Message theMsg = this.createMessage(state, isResponse);
            try {
                thePipe.sendMessage(theMsg);
                result = true;
            } catch (IOException ex) {
                // FIXME evaluate log level
                if (_pipelogger.isLoggable(Level.FINE)) {
                    _pipelogger.log(Level.FINE, "Exception sending message " + theMsg.toString(), ex);
View Full Code Here

Examples of net.jxta.util.JxtaBiDiPipe

    }    
   
    public String initPipes(int numPipes) {
       
        int i=0;
        JxtaBiDiPipe firstPipe = null;
        boolean connected = false;
        if (_pipelogger.isLoggable(Level.FINE)) {
            _pipelogger.fine("Waiting for JxtaBidiPipe connections on JxtaServerPipe");
        }
        ArrayList pipeWrappers = new ArrayList();
        String sourceInstanceName = null;
        while (i < numPipes) {
            try {
                if (_pipelogger.isLoggable(Level.FINER)) {
                    _pipelogger.finer("JxtaServerPipeWrapper:JxtaBidiPipe# " + i + " waiting to accept");
                }
                JxtaBiDiPipe bipipe = serverPipe.accept();
                sourceInstanceName = bipipe.getRemotePeerAdvertisement().getName();
                if (_pipelogger.isLoggable(Level.FINEST)) {
                    _pipelogger.finest("sourceInstanceName=" + sourceInstanceName);
                }
                //for each pipe, create and register handler with manager
                //later this can be a collection or pool in manager
                if (bipipe != null) {
                    //ConnectionHandler handler = new ConnectionHandler(bipipe);
                    PipeWrapper pipeWrapper = new PipeWrapper("pipe#" + i, PipeWrapper.RECEIVER_PIPE, sourceInstanceName, bipipe);
                    bipipe.setMessageListener(pipeWrapper);
                    bipipe.setPipeEventListener(pipeWrapper);
                    if(i == 0) {
                        //first one is health pipe
                        //JxtaSenderPipeManager.createInstance().setHealthPipeWrapper(pipeWrapper);
                        //JxtaReceiverPipeManager.createInstance().setHealthPipeWrapper(pipeWrapper);
                        JxtaReceiverPipeManager.createInstance().setHealthPipeWrapper(pipeWrapper, sourceInstanceName);
View Full Code Here

Examples of net.jxta.util.JxtaBiDiPipe

        while (threadContinue) {
            try {
                if (_pipelogger.isLoggable(Level.FINE)) {
                    _pipelogger.fine("JxtaServerPipeWrapper:JxtaBidiPipe# waiting to accept");
                }
                JxtaBiDiPipe bipipe = serverPipe.accept();
                sourceInstanceName = bipipe.getRemotePeerAdvertisement().getName();          
                if (_pipelogger.isLoggable(Level.FINE)) {
                    _pipelogger.fine("JxtaServerPipeWrapper:incoming pipe request accepted - sourceInstanceName=" + sourceInstanceName +
                                 " pipeAdv = " + bipipe.getRemotePeerAdvertisement().toString());
                }
                //for each pipe, create and register handler with manager
                //later this can be a collection or pool in manager
                if (bipipe != null && !(sourceInstanceName.equals(this.getInstanceName())) ) {
                    PipeWrapper pipeWrapper = new PipeWrapper("pipe", PipeWrapper.RECEIVER_PIPE, sourceInstanceName, bipipe);
                    bipipe.setMessageListener(pipeWrapper);
                    bipipe.setPipeEventListener(pipeWrapper);
                    //JxtaReceiverPipeManager.createInstance().addPipeWrapper(pipeWrapper);
                    JxtaReceiverPipeManager.createInstance().addPipeWrapper(pipeWrapper, sourceInstanceName);                 
                    if (_pipelogger.isLoggable(Level.FINE)) {
                        _pipelogger.fine("JxtaServerPipeWrapper:JxtaBidiPipe accepted added to pool(sourceInstanceName=" +
                                     sourceInstanceName + "), " + " ready for sending messages to the other end");
View Full Code Here

Examples of net.jxta.util.JxtaBiDiPipe

        if (_pipelogger.isLoggable(Level.FINE)) {
            _pipelogger.fine("using health pipe: sending 100 messages to the other end");
        }
        PipeWrapper pipeWrapper =
            JxtaReceiverPipeManager.createInstance().getHealthPipeWrapper(sourceInstanceName);
        JxtaBiDiPipe bipipe = pipeWrapper.getPipe();
        Thread thread = new Thread(new ConnectionHandler(bipipe), "Connection Handler Thread");
        thread.start();
    }   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.