Package org.nasutekds.server.replication.common

Examples of org.nasutekds.server.replication.common.ServerState


      = new ReplServerStartDSMsg(
          replicationServerId,
          replicationServerURL,
          getServiceId(),
          maxRcvWindow,
          new ServerState(),
          protocolVersion,
          localGenerationId,
          sslEncryption,
          getLocalGroupId(),
          0,
View Full Code Here


            {
              // when there is no cookie provided in the request,
              // let's start traversing this domain from the beginning of
              // what we have in the replication changelog
              if (newDomainCtxt.startState == null)
                newDomainCtxt.startState = new ServerState();
            }
            else
            {
              // when there is a cookie provided in the request,
              if (newDomainCtxt.startState == null)
              {
                missingDomains += (rsd.getBaseDn() + ":;");
                continue;
              }
              else if (!newDomainCtxt.startState.isEmpty())
              {
                // when the provided startState is older than the replication
                // changelogdb start state, it means that the replication
                // changelog db has been trimed and the cookie is not valid
                // anymore.
                boolean cookieTooOld = false;
                for (int serverId : rsd.getStartState())
                {
                  ChangeNumber dbOldestChange =
                    rsd.getStartState().getMaxChangeNumber(serverId);
                  ChangeNumber providedChange =
                    newDomainCtxt.startState.getMaxChangeNumber(serverId);
                  if ((providedChange != null)
                      && (providedChange.older(dbOldestChange)))
                  {
                    cookieTooOld=true;
                  }
                }

                if (cookieTooOld)
                {
                  // the provided start
                  throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                      ERR_RESYNC_REQUIRED_TOO_OLD_DOMAIN_IN_PROVIDED_COOKIE.get(
                          newDomainCtxt.rsd.getBaseDn()));
                }
              }
            }

            // Set the stop state for the domain from the eligibleCN
            newDomainCtxt.stopState = rsd.getEligibleState(eligibleCN, true);
          }
          newDomainCtxt.currentState = new ServerState();

          // Creates an unconnected SH for the domain
          MessageHandler mh = new MessageHandler(maxQueueSize,
              replicationServerURL, replicationServerId, replicationServer);
          // set initial state
View Full Code Here

   */
  public PersistentServerState(DN baseDn, int serverId)
  {
    this.baseDn = baseDn;
    this.serverId = serverId;
    this.state = new ServerState();
    this.asn1BaseDn = ByteString.valueOf(baseDn.toString());
    loadState();
  }
View Full Code Here

    MonitorData md;
    try
    {
      md = rsDomain.computeMonitorData(true);

      ServerState remoteState = md.getLDAPServerState(serverId);
      if (remoteState == null)
      {
        remoteState = new ServerState();
      }

      /* get the Server State */
      AttributeBuilder builder = new AttributeBuilder("server-state");
      for (String str : remoteState.toStringSet())
      {
        builder.add(str);
      }
      if (builder.size() == 0)
      {
View Full Code Here

   */
  public void addDependency(ChangeNumber changeNumber)
  {
    if (dependencyState == null)
    {
      dependencyState = new ServerState();
    }
    dependencyState.update(changeNumber);
  }
View Full Code Here

     *
     * Then creates a new PersistentServerState and check that the
     * 2 ChangeNumbers have been saved in this new PersistentServerState.
     */
    DN baseDn = DN.decode(dn);
    ServerState origState = new ServerState();
    PersistentServerState state =
      new PersistentServerState(baseDn,  1, origState);
    ChangeNumberGenerator gen1 =
      new ChangeNumberGenerator( 1, origState);
    ChangeNumberGenerator gen2 =
View Full Code Here

      replDomain.start();

      // Then check serverSate and GenId
      assertTrue(replDomain.getGenerationID() == 1225361491);

      ServerState state = replDomain.getServerState();
      assertTrue(state.getMaxChangeNumber( 1).
          compareTo(new ChangeNumber("0000011d4d42b240000100000000")) == 0);
      assertTrue(state.getMaxChangeNumber( 3).
          compareTo(new ChangeNumber("0000011d9a991110000300000000")) == 0);

    }
    finally
    {
View Full Code Here

       * DS2 starts and connects to RS1. No reader and low window value at the
       * beginning so writer for DS2 in RS should enqueue changes after first
       * changes sent to DS. (window value reached: a window msg needed by RS for
       * following sending changes to DS)
       */
      ds2 = createReplicationBroker(DS2_ID, new ServerState(), EMPTY_DN_GENID, 10);
      checkConnection(30, DS2_ID);

      /**
       * DS3 starts and connects to RS1
       */
      ds3 = createReplicationBroker(DS3_ID, new ServerState(), EMPTY_DN_GENID);
      br3 = new BrokerReader(ds3, DS3_ID);
      checkConnection(30, DS3_ID);

      // Send first changes to reach window and block DS2 writer queue. Writer will take them
      // from queue and block (no more changes removed from writer queue) after
View Full Code Here

      rs1 = createReplicationServer(testCase, DEGRADED_STATUS_THRESHOLD);

      /**
       * DS2 starts and connects to RS1
       */
      ds2 = createReplicationBroker(DS2_ID, new ServerState(), EMPTY_DN_GENID);
      br = new BrokerReader(ds2, DS2_ID);
      checkConnection(30, DS2_ID);

      /**
       * DS2 starts sending a lot of changes
       */
      bw = new BrokerWriter(ds2, DS2_ID, false);
      bw.follow();
      sleep(1000); // Let some messages being queued in RS

      /**
       * DS1 starts and connects to RS1, server state exchange should lead to
       * start in degraded status as some changes should be in queued in the RS
       * and the threshold value is 1 change in queue.
       */
      ds1 = createReplicationDomain(DS1_ID);
      checkConnection(30, DS1_ID);
      sleepAssertStatusEquals(30, ds1, ServerStatus.DEGRADED_STATUS);

      /**
       * DS2 stops sending changes: DS1 should replay pending changes and should
       * enter the normal status
       */
      bw.pause();
      // Sleep enough so that replay can be done and analyzer has time
      // to see that the queue length is now under the threshold value.
      sleepAssertStatusEquals(30, ds1, ServerStatus.NORMAL_STATUS);

      /**
       * RS1 stops to make DS1 go to not connected status (from normal status)
       */
      rs1.remove();
      sleepAssertStatusEquals(30, ds1, ServerStatus.NOT_CONNECTED_STATUS);

      /**
       * DS2 restarts with up to date server state (this allows to have
       * restarting RS1 not sending him some updates he already sent)
       */
      ds2.stop();
      bw.shutdown();
      br.shutdown();
      ServerState curState = ds1.getServerState();
      ds2 = createReplicationBroker(DS2_ID, curState, EMPTY_DN_GENID);
      br = new BrokerReader(ds2, DS2_ID);

      /**
       * RS1 restarts, DS1 should get back to normal status
View Full Code Here

  @Test(dataProvider = "changeNumberData")
  public void serverStateTest(ChangeNumber cn)
         throws Exception
  {
    // Check constructor
    ServerState serverState = new ServerState() ;

    // Check Load
    // serverState.loadState() ;
    // TODO Check result;

    // Check update
    assertFalse(serverState.update((ChangeNumber)null));
    assertTrue(serverState.update(cn));
    assertFalse(serverState.update(cn));
    ChangeNumber cn1, cn2, cn3;
    cn1 = new ChangeNumber(cn.getTime()+1,cn.getSeqnum(),cn.getServerId());
    cn2 = new ChangeNumber(cn1.getTime(),cn1.getSeqnum()+1,cn1.getServerId());
    cn3 = new ChangeNumber(cn2.getTime(),cn2.getSeqnum(),(cn2.getServerId()+1));

    assertTrue(serverState.update(cn1)) ;
    assertTrue(serverState.update(cn2)) ;
    assertTrue(serverState.update(cn3)) ;

    // Check toStringSet
    ChangeNumber[] cns = {cn2,cn3};
    Set<String> stringSet = serverState.toStringSet();
    assertEquals(cns.length, stringSet.size());
    // TODO Check the value

    // Check getMaxChangeNumber
    assertEquals(cn2.compareTo(serverState.getMaxChangeNumber(cn2.getServerId())),0);
    assertEquals(cn3.compareTo(serverState.getMaxChangeNumber(cn3.getServerId())),0);

    // Check the toString
    String stringRep = serverState.toString();
    assertTrue(stringRep.contains(cn2.toString()));
    assertTrue(stringRep.contains(cn3.toString()));

    // Check getBytes
    byte[] b = serverState.getBytes();
    ServerState generatedServerState = new ServerState(b,0,b.length -1) ;



    assertEquals(b, generatedServerState.getBytes()) ;

  }
View Full Code Here

TOP

Related Classes of org.nasutekds.server.replication.common.ServerState

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.