Package com.linkedin.databus.client.pub

Examples of com.linkedin.databus.client.pub.ServerInfo$ServerInfoSetBuilder


    // ServerSetChange when New Set includes CurrentServer
    {
      Assert.assertEquals(bsPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
      Assert.assertEquals(bsPuller.getCurentServer() != null, true, "Current Server not Null");
      ServerInfo oldServer = bsPuller.getCurentServer();
      Assert.assertEquals(bsPuller.getServers(),EXP_SERVERINFO_1,"Server Set");
      doExecuteAndChangeState(bsPuller,createSetServerMessage(true, bsPuller));
      Assert.assertEquals(bsPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
      Assert.assertEquals(bsPuller.getCurentServer(), oldServer, "Current Server unchanged");
      Assert.assertEquals(bsPuller.getServers(),EXP_SERVERINFO_2,"Server Set");
View Full Code Here


    // ServerSetChange when New Set includes CurrentServer
    {
      Assert.assertEquals(bsPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
      Assert.assertEquals(bsPuller.getCurentServer() != null, true, "Current Server not Null");
      ServerInfo oldServer = bsPuller.getCurentServer();
      Assert.assertEquals(bsPuller.getServers(),EXP_SERVERINFO_1,"Server Set");

      entries = new HashMap<Long, List<RegisterResponseEntry>>();
      entries.put(1L, new ArrayList<RegisterResponseEntry>());
      connState.setSourcesSchemas(entries);

      doExecuteAndChangeState(bsPuller,createSetServerMessage(true, bsPuller));
      Assert.assertEquals(bsPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
      Assert.assertEquals(bsPuller.getCurentServer(), oldServer, "Current Server unchanged");
      Assert.assertEquals(bsPuller.getServers(),EXP_SERVERINFO_2,"Server Set");
      Assert.assertEquals(bsPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
      Assert.assertEquals(connState.getStateId(),StateId.TARGET_SCN_REQUEST_SENT, "ServerSetChange while TARGET_SCN_REQUEST_SENT");
      Assert.assertEquals(bsPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while TARGET_SCN_REQUEST_SENT");
      Assert.assertTrue(cp.isSnapShotSourceCompleted(), "Phase completed");
      Assert.assertEquals(cp.getConsumptionMode(), DbusClientMode.BOOTSTRAP_SNAPSHOT, "Consumption Mode check");
    }

    // ServerSetChange when New Set excludes CurrentServer and SuccessFul Response
    {
      int oldServerIndex = bsPuller.getCurrentServerIdx();
      ServerInfo oldServer = bsPuller.getCurentServer();
      Assert.assertEquals(bsPuller.getServers(),EXP_SERVERINFO_2,"Server Set");

      entries = new HashMap<Long, List<RegisterResponseEntry>>();
      entries.put(1L, new ArrayList<RegisterResponseEntry>());
      connState.setSourcesSchemas(entries);
View Full Code Here

    // ServerSetChange when New Set includes CurrentServer
    {
      Assert.assertEquals(bsPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
      Assert.assertEquals(bsPuller.getCurentServer() != null, true, "Current Server not Null");
      ServerInfo oldServer = bsPuller.getCurentServer();
      Assert.assertEquals(bsPuller.getServers(),EXP_SERVERINFO_1,"Server Set");

      entries = new HashMap<Long, List<RegisterResponseEntry>>();
      entries.put(1L, new ArrayList<RegisterResponseEntry>());
      connState.setSourcesSchemas(entries);

      doExecuteAndChangeState(bsPuller,createSetServerMessage(true, bsPuller));
      Assert.assertEquals(bsPuller.getCurrentServerIdx() != -1, true, "Current Server Index defined");
      Assert.assertEquals(bsPuller.getCurentServer(), oldServer, "Current Server unchanged");
      Assert.assertEquals(bsPuller.getServers(),EXP_SERVERINFO_2,"Server Set");
      Assert.assertEquals(bsPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
      Assert.assertEquals(connState.getStateId(),StateId.TARGET_SCN_RESPONSE_SUCCESS, "ServerSetChange while TARGET_SCN_RESPONSE_SUCCESS");
      Assert.assertEquals(bsPuller.getQueueListString(), "RelayPuller queue: [TARGET_SCN_RESPONSE_SUCCESS]", "Queue :ServerSetChange while TARGET_SCN_RESPONSE_SUCCESS");
    }

    // ServerSetChange when New Set excludes CurrentServer and SuccessFul Response
    {
      int oldServerIndex = bsPuller.getCurrentServerIdx();
      ServerInfo oldServer = bsPuller.getCurentServer();
      Assert.assertEquals(bsPuller.getServers(),EXP_SERVERINFO_2,"Server Set");

      entries = new HashMap<Long, List<RegisterResponseEntry>>();
      entries.put(1L, new ArrayList<RegisterResponseEntry>());
      connState.setSourcesSchemas(entries);
View Full Code Here

  private ServerSetChangeMessage createSetServerMessage(boolean keepCurrent, BasePullThread puller)
  {
    Set<ServerInfo> serverInfoSet = new HashSet<ServerInfo>();
  InetSocketAddress inetAddr1 = new InetSocketAddress("localhost",10000);

  ServerInfo s = new ServerInfo("newBs1", "ONLINE", inetAddr1, Arrays.asList("source1"));
  serverInfoSet.add(s);

  if ( keepCurrent )
  {
    serverInfoSet.addAll(puller.getServers());
View Full Code Here

      return;
    }

    boolean restartBootstrap = false;
    String bsServerInfo = _resumeCkpt.getBootstrapServerInfo();
    ServerInfo lastReadBS = null;
    if ( null != bsServerInfo)
    {
      try
      {
        lastReadBS = ServerInfo.buildServerInfoFromHostPort(bsServerInfo, DbusConstants.HOSTPORT_DELIMITER);
      } catch(Exception ex) {
        _log.error("Unable to fetch bootstrap serverInfo from checkpoint, ServerInfo :" + bsServerInfo, ex);
      }
    }

    if ( null == lastReadBS)
      restartBootstrap = true;

    int retriesLeft = 0;
    DatabusBootstrapConnection bootstrapConn = null;
    ServerInfo serverInfo = lastReadBS;
    if ( !restartBootstrap )
    {
        //attempt to reconnect to the last used bootstrap server
        while (null == bootstrapConn && (retriesLeft = _retriesBeforeCkptCleanup.getRemainingRetriesNum()) >= 0
               && !checkForShutdownRequest())
        {

            _log.info("Retry picking last used bootstrap server :" + serverInfo +
                      "; retries left:" + retriesLeft);

            if (lastReadBS.equals(_curServer) ) // if it is new server do not sleep?
              _retriesBeforeCkptCleanup.backoffAndSleep();

            try
            {
              bootstrapConn = _sourcesConn.getBootstrapConnFactory().createConnection(serverInfo, this,
                                                                                      _remoteExceptionHandler);
              _log.info("picked last used bootstrap server:" + serverInfo);
            }
            catch (Exception e)
            {
              _log.error("Unable to get connection to bootstrap server:" + serverInfo, e);
            }
        }

        if ((null == bootstrapConn) && (_retriesBeforeCkptCleanup.getRemainingRetriesNum() < 0))
        {
          _log.info("Exhausted retrying the same bootstrap server :" + lastReadBS);
        }
    }

    if(checkForShutdownRequest()) {
      _log.info("Shutting down bootstrap");
      return;
    }

    Random rng = new Random();

    if ( null == bootstrapConn)
    {
      _log.info("Restarting bootstrap as client might be getting bootstrap data from different server instance !!");
      _log.info("Old Checkpoint :" + _resumeCkpt);
      curState.getBstCheckpointHandler().resetForServerChange(_resumeCkpt);
      _log.info("New Checkpoint :" + _resumeCkpt);
      _retriesBeforeCkptCleanup.reset();
    else {
        _curServer = serverInfo;
    }

    while ((null == bootstrapConn) && (retriesLeft = _status.getRetriesLeft()) >= 0 &&
           !checkForShutdownRequest())
    {
      _log.info("picking a bootstrap server; retries left:" + retriesLeft);

      backoffOnPullError();

      _curServerIdx =  (_curServerIdx < 0) ? rng.nextInt(serversNum)
                                           : (_curServerIdx + 1) % serversNum;

      Iterator<ServerInfo> setIter = _servers.iterator();
      for (int i = 0; i <= _curServerIdx; ++i) serverInfo = setIter.next();

      _curServer = serverInfo;

      try
      {
        bootstrapConn = _sourcesConn.getBootstrapConnFactory().createConnection(serverInfo, this, _remoteExceptionHandler);
        _log.info("picked a bootstrap server:" + serverInfo.toSimpleString());
      }
      catch (Exception e)
      {
        _log.error("Unable to get connection to bootstrap server:" + serverInfo, e);
      }
    }

    /*
     * Close the old bootstrap Connection
     */
     DatabusBootstrapConnection oldBootstrapConn = curState.getBootstrapConnection();

     if ( null != oldBootstrapConn)
         resetConnectionAndSetFlag();
     _lastOpenConnection = bootstrapConn;

    if (checkForShutdownRequest()) return;

    if (null == bootstrapConn)
    {
      _log.error("bootstrap server retries exhausted");
      enqueueMessage(LifecycleMessage.createSuspendOnErroMessage(new DatabusException("bootstrap server retries exhausted")));
      return;
    }

    sendHeartbeat(_sourcesConn.getUnifiedClientStats());

    curState.bootstrapServerSelected(serverInfo.getAddress(), bootstrapConn, _curServer);

    //determine what to do next based on the current checkpoint
    _log.info("resuming bootstrap from checkpoint: " + _resumeCkpt);
    curState.setCheckpoint(_resumeCkpt);
    determineNextStateFromCheckpoint(curState);
View Full Code Here

    {
      tearConnectionAndEnqueuePickServer();
    }
    else
    {
      ServerInfo bsServerInfo = curState.getCurrentBSServerInfo();
      if ( null == bsServerInfo)
      {
        String msg = "Bootstrap Server did not provide its server info in StartSCN !! Switching to PICK_SERVER. CurrentServer :" + _curServer;
        _log.error(msg);
          curState.switchToStartScnResponseError();
      }
      else if (! bsServerInfo.equals(_curServer)){
        // Possible for VIP case
        _log.info("Bootstrap server responded and current server does not match. Switching to Pick Server !!  curServer: "
                        + _curServer + ", Responded Server :" + bsServerInfo);
        _log.info("Checkpoint before clearing :" + _resumeCkpt);
        String bsServerInfoStr = _resumeCkpt.getBootstrapServerInfo();
View Full Code Here

  }


  private void doRemoveServer(ServerSetChangeMessage serverSetChangeMsg)
  {
    ServerInfo newServer = serverSetChangeMsg.getServer();

    _log.info("About to remove Server (" + newServer + ") from Server set. Current Server set is :" + _servers);

    if (null == newServer)
    {
      _log.error("No Server to remove");
      return;
    }

    if (! _servers.contains(newServer))
    {
      _log.warn("Trying to remove a Server that does not exist:" + newServer.toString());
    }
    else
    {
      _log.info("Removing Server: " + newServer.toString());
      Iterator<ServerInfo> iter = _servers.iterator();
      int index = 0;
      for (; iter.hasNext(); ++index)
      {
        if(newServer.equals(iter.next()))
          break;
      }

      if ( index < _curServerIdx )
      {
View Full Code Here

    resetServerRetries();
  }

  private void doAddServer(ServerSetChangeMessage serverSetChangeMsg)
  {
    ServerInfo newServer = serverSetChangeMsg.getServer();

    _log.info("About to add new Server (" + newServer + ") to Server set. Current Server set is :" + _servers);

    if (null == newServer)
    {
      _log.error("No new Server to add");
      return;
    }

    if (_servers.contains(newServer))
    {
      _log.warn("Server already exists:" + newServer.toString() + " Skipping this addition !!");
    }
    else
    {
      _log.info("Adding new Server: " + newServer.toString());
      _servers.add(newServer);
    }

    resetServerRetries();
  }
View Full Code Here

    ServerInfoBuilder relayConfigBuilder = rtConfigBuilder.getRelay(Integer.toString(id));
    relayConfigBuilder.setName(name);
    relayConfigBuilder.setHost(addr.getHostName());
    relayConfigBuilder.setPort(addr.getPort());
    relayConfigBuilder.setSources(sources);
    ServerInfo si = relayConfigBuilder.build();
    client.getClientConfigManager().setNewConfig(rtConfigBuilder.build());
    return si;
  }
View Full Code Here

    DatabusHttpClientImpl.Config clientConfig = new DatabusHttpClientImpl.Config();
    clientConfig.getContainer().getJmx().setRmiEnabled(false);
      clientConfig.getContainer().setHttpPort(10100);
    DatabusHttpClientImpl client = new DatabusHttpClientImpl(clientConfig);

      ServerInfo s1 = registerRelay(1, "relay1", new InetSocketAddress("localhost", 8888), "S1,S2", client);
      @SuppressWarnings("unused")
      ServerInfo s2 = registerRelay(2, "relay2", new InetSocketAddress("localhost", 7777), "S1,S3", client);
      ServerInfo s11 = registerRelay(3, "relay1.1", new InetSocketAddress("localhost", 8887), "S1,S2", client);

      DummyStreamConsumer listener1 = new DummyStreamConsumer("consumer1");
      client.registerDatabusStreamListener(listener1 , null, "S2");

      try
View Full Code Here

TOP

Related Classes of com.linkedin.databus.client.pub.ServerInfo$ServerInfoSetBuilder

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.