Package org.teiid.net

Examples of org.teiid.net.CommunicationException


            keyGen = new DhKeyGenerator();
            byte[] publicKey;
      try {
        publicKey = keyGen.createPublicKey();
      } catch (CryptoException e) {
        throw new CommunicationException(e);
      }
            handshake.setPublicKey(publicKey);
        }
        this.objectSocket.write(handshake);
  }
View Full Code Here


    if (usingEncryption) {
            byte[] returnedPublicKey = handshake.getPublicKey();
           
            //ensure the key information
            if (returnedPublicKey == null) {
                throw new CommunicationException(RuntimePlugin.Util.getString("SocketClientInstance.invalid_sessionkey")); //$NON-NLS-1$
            }
           
            try {
        this.cryptor = keyGen.getSymmetricCryptor(returnedPublicKey);
      } catch (CryptoException e) {
        throw new CommunicationException(e);
      }
            this.keyGen = null;
        } else {
            this.cryptor = new NullCryptor();
        }
View Full Code Here

            throw new ConnectionException(e, e.getMessage());
        } catch (TeiidComponentException e) {
          if (e.getCause() instanceof CommunicationException) {
            throw (CommunicationException)e.getCause();
          }
            throw new CommunicationException(e);
        }  
  } 
View Full Code Here

      for (int i = 0; i < HANDSHAKE_RETRIES; i++) {
          try {
        Object obj = this.socketChannel.read();
       
        if (!(obj instanceof Handshake)) {
          throw new CommunicationException(JDBCPlugin.Util.getString("SocketServerInstanceImpl.handshake_error"))//$NON-NLS-1$
        }
        handshake = (Handshake)obj;
        break;
      } catch (ClassNotFoundException e1) {
        throw new CommunicationException(e1);
      } catch (SocketTimeoutException e) {
        if (i == HANDSHAKE_RETRIES - 1) {
          throw e;
        }
      }
      }

        try {
            /*if (!getVersionInfo().equals(handshake.getVersion())) {
                throw new CommunicationException(NetPlugin.Util.getString("SocketServerInstanceImpl.version_mismatch", getVersionInfo(), handshake.getVersion())); //$NON-NLS-1$
            }*/
            serverVersion = handshake.getVersion();
            handshake.setVersion();
           
            byte[] serverPublicKey = handshake.getPublicKey();
           
            if (serverPublicKey != null) {
              DhKeyGenerator keyGen = new DhKeyGenerator();
              byte[] publicKey = keyGen.createPublicKey();
                this.cryptor = keyGen.getSymmetricCryptor(serverPublicKey);
                handshake.setPublicKey(publicKey);
            } else {
                this.cryptor = new NullCryptor();
            }
           
            this.socketChannel.write(handshake);
        } catch (CryptoException err) {
          throw new CommunicationException(err);
        }
    }
View Full Code Here

    if (ssl) {
      if (this.sslSocketFactory == null) {
        try {
          sslSocketFactory = SocketUtil.getSSLSocketFactory(props);
        } catch (GeneralSecurityException e) {
          throw new CommunicationException(e);
        }
      }
      socket = sslSocketFactory.getSocket();
    } else {
      socket = new Socket();
View Full Code Here

   * @throws ConnectionException
   */
  public synchronized SocketServerInstance selectServerInstance(boolean logoff)
      throws CommunicationException, ConnectionException {
    if (closed) {
      throw new CommunicationException(JDBCPlugin.Util.getString("SocketServerConnection.closed")); //$NON-NLS-1$
    }
    if (this.serverInstance != null && (!failOver || this.serverInstance.isOpen())) {
      return this.serverInstance;
    }
    List<HostInfo> hostKeys = new ArrayList<HostInfo>(this.serverDiscovery.getKnownHosts(logonResult, null));
    boolean discoverHosts = true;
    closeServerInstance();
    List<HostInfo> hostCopy = new ArrayList<HostInfo>(hostKeys);
    int knownHosts = hostKeys.size();
    while (hostKeys.size() > 0) {
      HostInfo hostInfo = this.serverDiscovery.selectNextInstance(hostKeys);

      Exception ex = null;
      try {
        if (!hostInfo.isResolved()) {
          hostInfo = new HostInfo(hostInfo.getHostName(), new InetSocketAddress(hostInfo.getInetAddress(), hostInfo.getPortNumber()));
        }
        ILogon newLogon = connect(hostInfo);
        if (this.logonResult == null) {
              try {
                  logon(newLogon, logoff);
            this.serverDiscovery.connectionSuccessful(hostInfo);
                  if (discoverHosts) {
                    List<HostInfo> updatedHosts = this.serverDiscovery.getKnownHosts(logonResult, this.serverInstance);
                    if (updatedHosts.size() > 1 && new HashSet<HostInfo>(updatedHosts).size() > new HashSet<HostInfo>(hostCopy).size()) {
                      hostKeys = updatedHosts;
                      closeServerInstance();
                      discoverHosts = false;
                      continue;
                    }
                  }
              } catch (LogonException e) {
                  // Propagate the original message as it contains the message we want
                  // to give to the user
                  throw new ConnectionException(e, e.getMessage());
              } catch (TeiidComponentException e) {
                if (e.getCause() instanceof CommunicationException) {
                  throw (CommunicationException)e.getCause();
                }
                  throw new CommunicationException(e, JDBCPlugin.Util.getString("PlatformServerConnectionFactory.Unable_to_find_a_component_used_in_logging_on_to")); //$NON-NLS-1$
              }
        }
        return this.serverInstance;
      } catch (IOException e) {
        ex = e;
      } catch (SingleInstanceCommunicationException e) {
        ex = e;
      }  
      this.serverDiscovery.markInstanceAsBad(hostInfo);
      if (knownHosts == 1) { //just a single host, use the exception
        if (ex instanceof UnknownHostException) {
          throw new SingleInstanceCommunicationException(ex, JDBCPlugin.Util.getString("SocketServerInstance.Connection_Error.Unknown_Host", hostInfo.getHostName())); //$NON-NLS-1$
        }
        throw new SingleInstanceCommunicationException(ex,JDBCPlugin.Util.getString("SocketServerInstance.Connection_Error.Connect_Failed", hostInfo.getHostName(), String.valueOf(hostInfo.getPortNumber()), ex.getMessage())); //$NON-NLS-1$
      }
      log.log(Level.FINE, "Unable to connect to host", ex); //$NON-NLS-1$
    }
    throw new CommunicationException(JDBCPlugin.Util.getString("SocketServerInstancePool.No_valid_host_available", hostCopy.toString())); //$NON-NLS-1$
  }
View Full Code Here

        }
        lastPing = System.currentTimeMillis();
        try {
          return selectServerInstance(false);
        } catch (ConnectionException e) {
          throw new CommunicationException(e);
        }
      }
     
      public Object invoke(Object proxy, Method method, Object[] args)
          throws Throwable {
View Full Code Here

    }
  }
 
  private synchronized ResultsFuture<?> isOpen() throws CommunicationException, InvalidSessionException, TeiidComponentException {
    if (this.closed) {
      throw new CommunicationException();
    }
    return logon.ping();
  }
View Full Code Here

      return false;
    }
    try {
      return selectServerInstance(false).getHostInfo().equals(((SocketServerConnection)otherService).selectServerInstance(false).getHostInfo());
    } catch (ConnectionException e) {
      throw new CommunicationException(e);
    }
  }
View Full Code Here

      try {
        this.logon(logonInstance, true);
      } catch (LogonException e) {
        throw new ConnectionException(e);
      } catch (TeiidComponentException e) {
        throw new CommunicationException(e);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.teiid.net.CommunicationException

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.