Package org.teiid.net

Examples of org.teiid.net.HostInfo


   
    ClientServiceRegistryImpl server;
    private ResultsReceiver<Object> listener;

    public FakeClientServerInstance(ClientServiceRegistryImpl server) throws UnknownHostException {
      super(new HostInfo("foo", new InetSocketAddress(InetAddress.getLocalHost(), 1)), 1000);
      this.server = server;
    }
View Full Code Here


    listener = createListener(addr, config);
    listener1 = createListener(addr, config);
    listener1.stop();
    Properties p = new Properties();
    TeiidURL teiidUrl = new TeiidURL(addr.getHostName(), listener.getPort(), clientSecure);
    teiidUrl.getHostInfo().add(new HostInfo(addr.getHostName(), listener1.getPort()));
    String url = teiidUrl.getAppServerURL();
    p.setProperty(TeiidURL.CONNECTION.SERVER_URL, url);
    p.setProperty(TeiidURL.CONNECTION.DISCOVERY_STRATEGY, UrlServerDiscovery.class.getName());
    p.setProperty(TeiidURL.CONNECTION.AUTO_FAILOVER, Boolean.TRUE.toString());
    if (sscf == null) {
View Full Code Here

    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

  private SocketServerConnection createConnection(final Throwable throwException) throws CommunicationException, ConnectionException {
    return createConnection(throwException, new Properties());
  }
 
  private SocketServerConnection createConnection(final Throwable throwException, Properties p) throws CommunicationException, ConnectionException {
    return createConnection(throwException, new HostInfo("0.0.0.2", 1), p); //$NON-NLS-1$
  }
View Full Code Here

    SocketServerConnection connection = new SocketServerConnection(instanceFactory, false, discovery, p);
    return connection;
  }
 
  @Test public void testIsSameInstance() throws Exception {
    SocketServerConnection conn = createConnection(null, new HostInfo("0.0.0.0", 1), new Properties()); //$NON-NLS-1$
    SocketServerConnection conn1 = createConnection(null, new HostInfo("0.0.0.1", 1), new Properties()); //$NON-NLS-1$
   
    assertFalse(conn.isSameInstance(conn1));
    assertTrue(conn.isSameInstance(conn));
  }
View Full Code Here

    }
  }

  private SocketServerInstanceImpl createInstance(ObjectChannelFactory channelFactory)
      throws CommunicationException, IOException {
    HostInfo info = new HostInfo("0.0.0.0", 1);
    SocketServerInstanceImpl ssii = new SocketServerInstanceImpl(info, 1);
    ssii.connect(channelFactory);
    return ssii;
  }
View Full Code Here

TOP

Related Classes of org.teiid.net.HostInfo

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.