Package org.xmlBlaster.util.qos.address

Examples of org.xmlBlaster.util.qos.address.Address


   public final Address getBootstrapAddress() {
      if (this.bootstrapAddress == null) {
         synchronized (this) {
            if (this.bootstrapAddress == null) {
               if (log.isLoggable(Level.FINER)) log.finer("Entering getBootstrapAddress(), trying to resolve one ...");
               this.bootstrapAddress = new Address(this);
               if (log.isLoggable(Level.FINE)) log.fine("Initialized bootstrapAddress to host=" + this.bootstrapAddress.getBootstrapHostname() +
                              " port=" + this.bootstrapAddress.getBootstrapPort() + ", rawAddress='" + this.bootstrapAddress.getRawAddress()+"'");
               this.bootstrapAddress.setRawAddress(this.bootstrapAddress.getBootstrapUrl());
            }
         }
View Full Code Here


    * </ol>
    * @return The default IP, is never null
    */
   public String getCbHostname() {
      if (this.cbHostname == null) {
         Address addr = getBootstrapAddress();
         this.cbHostname = getProperty().get("bootstrapHostnameCB",
                           getCbHostname(addr.getBootstrapHostname(), addr.getBootstrapPort()));
      }
      return this.cbHostname;
   }
View Full Code Here

   public String accessFromInternalHttpServer(Address address, String urlPath, boolean verbose) throws XmlBlasterException
   {
      if (log.isLoggable(Level.FINER))
         log.finer("Entering accessFromInternalHttpServer(" + ((address==null)?"null":address.getRawAddress()) + ") ...");
      //log.info(ME, "accessFromInternalHttpServer address=" + address.toXml());
      Address addr = address;
      if (addr != null && addr.getBootstrapPort() > 0) {
         if (addr.getBootstrapHostname() == null || addr.getBootstrapHostname().length() < 1) {
            addr.setBootstrapHostname(getLocalIP());
         }
      }
      else {
         addr = getBootstrapAddress();
      }

      try {
         if (urlPath != null && urlPath.startsWith("/") == false)
            urlPath = "/" + urlPath;

         if (log.isLoggable(Level.FINE))
            log.fine("Trying internal http server on " +
                               addr.getBootstrapHostname() + ":" + addr.getBootstrapPort() + "" + urlPath);
         java.net.URL nsURL = new java.net.URL("http", addr.getBootstrapHostname(), addr.getBootstrapPort(), urlPath);
         java.io.InputStream nsis = nsURL.openStream();
         byte[] bytes = new byte[4096];
         java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
         int numbytes;
         for (int ii=0; ii<20 && (nsis.available() <= 0); ii++) {
            if (log.isLoggable(Level.FINE)) log.fine("XmlBlaster on host " + addr.getBootstrapHostname() + " and bootstrapPort " + addr.getBootstrapPort() + " returns empty data, trying again after sleeping 10 milli ...");
            Timestamp.sleep(10); // On heavy logins, sometimes available() returns 0, but after sleeping it is OK
         }
         while (nsis.available() > 0 && (numbytes = nsis.read(bytes)) > 0) {
            bos.write(bytes, 0, numbytes);
         }
         nsis.close();
         String data = bos.toString();
         if (log.isLoggable(Level.FINE)) log.fine("Retrieved http data='" + data + "'");
         return data;
      }
      catch(MalformedURLException e) {
         String text = "XmlBlaster not found on host " + addr.getBootstrapHostname() + " and bootstrap port " + addr.getBootstrapPort() + ".";
         log.severe(text + e.toString());
         e.printStackTrace();
         throw new XmlBlasterException(this, ErrorCode.USER_CONFIGURATION, ME+"NoHttpServer", text, e);
      }
      catch(IOException e) {
         if (verbose) log.warning("XmlBlaster not found on host " + addr.getBootstrapHostname() + " and bootstrapPort " + addr.getBootstrapPort() + ": " + e.toString());
         throw new XmlBlasterException(this, ErrorCode.COMMUNICATION_NOCONNECTION, ME+"NoHttpServer",
                   "XmlBlaster not found on host " + addr.getBootstrapHostname() + " and bootstrap port " + addr.getBootstrapPort() + ".", e);
      }
   }
View Full Code Here

      cbAddress.setRetries(-1);
      cbAddress.setPingInterval(-1);
      cbAddress.setDelay(250L);
      qos.addCallbackAddress(cbAddress);
     
      Address clientAddress = qos.getAddress();
      clientAddress.setRetries(-1);
      clientAddress.setPingInterval(-1);
      clientAddress.setDelay(10000L);
     
      this.updateInterceptor.clear();
      this.global.getXmlBlasterAccess().connect(qos, updateInterceptor);
      if (shutdownCb) {
         try {
View Full Code Here

         ConnectQos connectQos = new ConnectQos(glob);

         ClientQueueProperty prop = new ClientQueueProperty(glob, null);
         prop.setMaxEntries(10000);    // Client side queue up to 10000 entries if not connected

         Address address = new Address(glob);
         address.setDelay(4000L);      // retry connecting every 4 sec
         address.setRetries(-1);       // -1 == forever
         address.setPingInterval(2000L)// ping every 2 sec

         // Example how to hardcode a XmlRpc server:
         //address.setType("XMLRPC");    // force XmlRpc protocol
         //address.setRawAddress("http://noty:9456/"); // Address to find the server
View Full Code Here

               ConnectQos tmpQos = new ConnectQos(glob, sessionName.getRelativeName(), "");
               tmpQos.getData().setSecurityQos(securityQos);
               tmpQos.setSessionName(sessionName);
               ClientQueueProperty prop = new ClientQueueProperty(glob, null);
               prop.setType("RAM");
               Address address = new Address(glob);
               address.setDelay(40000L);
               address.setRetries(-1);
               address.setPingInterval(20000L);
               address.setType(type);
               address.setVersion(version);
               //address.addClientProperty(new ClientProperty("useRemoteLoginAsTunnel", true));
               address.addClientProperty(new ClientProperty("acceptRemoteLoginAsTunnel", true));
               address.setRawAddress(rawAddress); // Address to find ourself
               //address.addClientProperty(new ClientProperty("acceptRemoteLoginAsTunnel", "", "", ""+true));
               prop.setAddress(address);
               tmpQos.addClientQueueProperty(prop);
               CallbackAddress cbAddress = new CallbackAddress(glob);
               cbAddress.setDelay(40000L);
               cbAddress.setRetries(-1);
               cbAddress.setPingInterval(20000L);
               cbAddress.setDispatcherActive(false);
               cbAddress.setType(type);
               cbAddress.setVersion(version);
               //cbAddress.addClientProperty(new ClientProperty("useRemoteLoginAsTunnel", true));
               cbAddress.addClientProperty(new ClientProperty("acceptRemoteLoginAsTunnel", true));
               tmpQos.addCallbackAddress(cbAddress);
               tmpQos.setPersistent(true);
               glob.getXmlBlasterAccess().setServerNodeId(getId());
               log.info("Creating temporary session " + sessionName.getRelativeName() + " until real cluster node "
                     + glob.getXmlBlasterAccess().getServerNodeId() + " arrives");
               glob.getXmlBlasterAccess().connect(tmpQos, new I_Callback() {
                  public String update(String cbSessionId, UpdateKey updateKey,
                        byte[] content, UpdateQos updateQos)
                        throws XmlBlasterException {
                     return null;
                  }
               });
               glob.getXmlBlasterAccess().leaveServer(null);
               myRemotePartnerLogin = this.fatherGlob.getRequestBroker().getAuthenticate(secretSessionId).getSessionInfo(sessionName);
              
               if (myRemotePartnerLogin == null) {
                  log.severe("Can't create session " + sessionName.getAbsoluteName());
                  return null;
               }
            }
           
            DispatchManager mgr = myRemotePartnerLogin.getDispatchManager();
            if (mgr != null) {
               boolean fireInitial = true;
                mgr.addConnectionStatusListener(new I_ConnectionStatusListener() {
                   // The !remote! node has logged in (not our client connection)
                   public void toAlive(DispatchManager dispatchManager, ConnectionStateEnum oldState) {
                      SessionInfo myRemotePartnerLogin = fatherGlob.getRequestBroker().getAuthenticate(secretSessionId).getSessionInfo(sessionName);
                      if (myRemotePartnerLogin != null && myRemotePartnerLogin.getAddressServer() != null) {
                         Object obj = myRemotePartnerLogin.getAddressServer().getCallbackDriver();
                         if (obj != null && obj instanceof CallbackSocketDriver) {
                            // cbDriver.callbackAddress: socket://192.168.1.20:8920
                            CallbackSocketDriver cbDriver = (CallbackSocketDriver)myRemotePartnerLogin.getAddressServer().getCallbackDriver();
                            log.info("toAlive(" + sessionName.getAbsoluteName() + ")... found existing session to back-tunnel '" + getId() + "' on address '" + myRemotePartnerLogin.getAddressServer().getRawAddress() + "' protocol=" + myRemotePartnerLogin.getAddressServer().getType() + " cbDriver-Handler " + ((cbDriver.getHandler()==null)?"null":cbDriver.getHandler().getAddressServer().getRawAddress()));
                            //log.severe("Register toAlive: CallbackSocketDriver.handler=" + cbDriver.getHandler());
                            remoteGlob.addObjectEntry(globalKey, cbDriver.getHandler());
                            log.info(sessionName.toString() + " Adding toAlive '" + cbDriver.getHandler() + "' entryKey=" + globalKey + " global.instanceId=" + remoteGlob.getInstanceId() + "-" + remoteGlob.hashCode());
                         }
                         else {
                            log.info("toAlive(" + sessionName.getAbsoluteName() + ")... no  CallbackSocketDriver to back-tunnel '" + getId() + "' found");
                            remoteGlob.addObjectEntry(globalKey, "dummyPlaceHolder");
                            log.info(sessionName.toString() + " Adding toAlive 'dummyPlaceHolder' entryKey=" + globalKey + " global.instanceId=" + remoteGlob.getInstanceId() + "-" + remoteGlob.hashCode());
                         }
                      }
                      else {
                         log.info("toAlive(" + sessionName.getAbsoluteName() + ")... no  session to back-tunnel '" + getId() + "' found");
                         remoteGlob.addObjectEntry(globalKey, "dummyPlaceHolder");
                         log.info(sessionName.toString() + " Adding toAlive 'dummyPlaceHolder' (myRemotePartnerLogin=null) entryKey=" + globalKey + " global.instanceId=" + remoteGlob.getInstanceId() + "-" + remoteGlob.hashCode());
                      }
                   }
                   public void toPolling(DispatchManager dispatchManager, ConnectionStateEnum oldState) {
                      log.warning("toPolling(" + sessionName.getAbsoluteName() + ") for cluster back-tunnel ...");
                      remoteGlob.addObjectEntry(globalKey, "dummyPlaceHolder");
                      log.info(sessionName.toString() + " Adding toPolling 'dummyPlaceHolder' entryKey=" + globalKey + " global.instanceId=" + remoteGlob.getInstanceId() + "-" + remoteGlob.hashCode());
                      if (oldState == ConnectionStateEnum.ALIVE)
                        ping(); // Force our client connection to POLLING as
                                // well
                   }
                   public void toDead(DispatchManager dispatchManager, ConnectionStateEnum oldState, XmlBlasterException xmlBlasterException) {
                      log.severe("toDead(" + sessionName.getAbsoluteName() + ") for cluster back-tunnel ...");
                      remoteGlob.addObjectEntry(globalKey, "dummyPlaceHolder");
                      log.info(sessionName.toString() + " Adding toDead 'dummyPlaceHolder' entryKey=" + globalKey + " global.instanceId=" + remoteGlob.getInstanceId() + "-" + remoteGlob.hashCode());
                      if (oldState == ConnectionStateEnum.ALIVE)
                        ping(); // Force our client connection to POLLING
                   }
                   public void toAliveSync(DispatchManager dispatchManager, ConnectionStateEnum oldState) {
                   }
                  
                }, fireInitial);
             }
            /* done by fireInitial
            if (myRemotePartnerLogin != null && myRemotePartnerLogin.getAddressServer() != null) {
               Object obj = myRemotePartnerLogin.getAddressServer().getCallbackDriver();
               if (obj != null && obj instanceof CallbackSocketDriver) {
                  CallbackSocketDriver cbDriver = (CallbackSocketDriver)myRemotePartnerLogin.getAddressServer().getCallbackDriver();
                  this.remoteGlob.addObjectEntry(globalKey, cbDriver.getHandler());
               }
            }
            */
         }
        
         boolean acceptRemoteLoginAsTunnel = connectQosData.getAddress().getEnv("acceptRemoteLoginAsTunnel", false).getValue(); //"heron".equals(qos.getSessionName().getLoginName());
         if (acceptRemoteLoginAsTunnel) { // The cluster slave accepts publish(), subscribe() etc callbacks
            this.remoteGlob.addObjectEntry("ClusterManager[cluster]/I_Authenticate", this.fatherGlob.getAuthenticate());
            this.remoteGlob.addObjectEntry("ClusterManager[cluster]/I_XmlBlaster", this.fatherGlob.getAuthenticate().getXmlBlaster());
         }

         this.xmlBlasterConnection = this.remoteGlob.getXmlBlasterAccess();
         this.xmlBlasterConnection.setUserObject(this);
         // force client side queue unique name, instead of setStorageIdStr()
         this.xmlBlasterConnection.setServerNodeId(getId());
         this.xmlBlasterConnection.registerConnectionListener(this);
         final XmlBlasterAccess xbAccess = (XmlBlasterAccess)this.xmlBlasterConnection;
         this.xmlBlasterConnection.registerPostSendListener(new I_PostSendListener() {
            public void postSend(MsgQueueEntry[] msgQueueEntries) {
             
            }
            // For example on user.security.authorization.notAuthorized
            public boolean sendingFailed(MsgQueueEntry[] entries,
          XmlBlasterException exception) {
               try {
                  for (int i=0; i<entries.length; i++) {
                     MsgUnit msgUnit = entries[i].getMsgUnit();              
                     String fn = xbAccess.getFileDumper().dumpMessage(msgUnit.getKeyData(), msgUnit.getContent(), msgUnit.getQosData());
                     log.severe("Async sending of cluster message failed for " + msgUnit.getKeyOid() +", is dumped to " + fn + ": " + exception.getMessage());
                  }
               }
               catch (Throwable e) {
                  e.printStackTrace();
                  for (int i=0; i<entries.length; i++)
                     log.severe("Async sending of message failed for message " + entries[i].toXml() +"\nreason is: " + exception.getMessage());
               }
              
               // If PtP send back to sender?
              
               return true; // Remove from connection queue! Now other messages can be delivered
            }
         });

         /*
          * // fixed to be unique since 1.5.2 boolean oldQueueNameBehavior =
          * this.remoteGlob.getProperty().get(
          * "xmlBlaster/cluster/useLegacyClientQueueName", false); if
          * (!oldQueueNameBehavior)
          * this.xmlBlasterConnection.setStorageIdStr(getId
          * ()+connectQosData.getSessionName().getRelativeName()); //now
          * setServerNodeId since 1.6.2+
          */
         try {
            Address addr = connectQosData.getAddress();
            log.info("Trying to connect to node '" + getId() + "' on address '" + addr.getRawAddress() + "' using protocol=" + addr.getType());

            // TODO: Check if physical IP:PORT is identical
            if (this.fatherGlob.getClusterManager().getMyClusterNode().getId().equals(getId())) {
               log.severe("We want to connect to ourself, route to node'" + getId() + "' ignored: ConnectQos=" + connectQosData.toXml());
               return null;
View Full Code Here

      I_Driver[] drivers = this.glob.getPluginRegistry().getPluginsOfInterfaceI_Driver();
      for (int i=0; i < drivers.length; i++) {
         I_Driver driver = drivers[i];
         String rawAddr = driver.getRawAddress();
         if (rawAddr != null) {
            Address addr = new Address(this.glob, driver.getProtocolId(), this.glob.getId());
            addr.setRawAddress(rawAddr);
            this.myClusterNode.getNodeInfo().addAddress(addr);
         }
      }
      if (drivers.length > 0) {
         if (log.isLoggable(Level.FINE)) log.fine("Setting " + drivers.length + " addresses for cluster node '" + getId() + "'");
View Full Code Here

    */
   private String getDefaultType() {
      if (this.defaultType == null) {
         synchronized (this) {
            if (this.defaultType == null) {
               Address def = new Address(glob);
               this.defaultType = def.getType();
               if (this.defaultType == null) {
                  this.defaultType = "SOCKET";
               }
            }
         }
View Full Code Here

   /** For testing: java org.xmlBlaster.util.qos.storage.ClientQueueProperty */
   public static void main(String[] args) {
      ClientQueueProperty prop = new ClientQueueProperty(new Global(args), null);
      System.out.println(prop.toXml());
      Address adr = new Address(new Global(args), "EMAIL");
      adr.setRawAddress("et@mars.sun");
      prop.setAddress(adr);
      System.out.println(prop.toXml());
   }
View Full Code Here

      if (log.isLoggable(Level.FINER)) log.finer("getAuthenticationService() ...");
      if (this.authServer != null) {
         return this.authServer;
      }

      address = (address == null) ? new Address(glob) : address;
      if (this.pluginInfo != null)
         address.setPluginInfoParameters(this.pluginInfo.getParameters());

      try {
         // 0) Check if programmer has given the IOR hardcoded
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.qos.address.Address

Copyright © 2018 www.massapicom. 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.