Example #1
0
  @Override
  @Before
  public void setUp() throws IOException {
    cluster = ServerTestUtils.getLocalCluster(2, new int[][] {{0, 1, 2, 3}, {4, 5, 6, 7}});
    servers = new VoldemortServer[2];

    servers[0] =
        ServerTestUtils.startVoldemortServer(
            ServerTestUtils.createServerConfig(
                useNio,
                0,
                TestUtils.createTempDir().getAbsolutePath(),
                null,
                storesXmlfile,
                new Properties()),
            cluster);
    servers[1] =
        ServerTestUtils.startVoldemortServer(
            ServerTestUtils.createServerConfig(
                useNio,
                1,
                TestUtils.createTempDir().getAbsolutePath(),
                null,
                storesXmlfile,
                new Properties()),
            cluster);

    adminClient = ServerTestUtils.getAdminClient(cluster);
  }
Example #2
0
  // This method is susceptible to BindException issues due to TOCTOU
  // problem with getLocalCluster (which is used to construct cluster that is
  // passed in).
  // TODO: Refactor AbstractRebalanceTest to take advantage of
  // ServerTestUtils.startVoldemortCluster.
  @Override
  protected Cluster startServers(
      Cluster cluster,
      String storeXmlFile,
      List<Integer> nodeToStart,
      Map<String, String> configProps)
      throws IOException {
    for (int node : nodeToStart) {
      Properties properties = new Properties();
      if (null != configProps) {
        for (Entry<String, String> property : configProps.entrySet()) {
          properties.put(property.getKey(), property.getValue());
        }
      }

      VoldemortConfig config =
          ServerTestUtils.createServerConfig(
              useNio,
              node,
              TestUtils.createTempDir().getAbsolutePath(),
              null,
              storeXmlFile,
              properties);

      VoldemortServer server =
          ServerTestUtils.startVoldemortServer(socketStoreFactory, config, cluster);
      serverMap.put(node, server);
    }

    return cluster;
  }
  @Before
  public void setup() throws IOException {
    byte[] bytes1 = {(byte) 'A', (byte) 'B'};
    byte[] bytes2 = {(byte) 'C', (byte) 'D'};
    List<StoreDefinition> stores = ClusterTestUtils.getZZZ322StoreDefs("memory");
    StoreDefinition storeDef = stores.get(0);
    cluster = ClusterTestUtils.getZZZCluster();
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setBootstrapUrls(cluster.getNodeById(0).getSocketUrl().toString());
    clientConfig.getZoneAffinity().setEnableGetOpZoneAffinity(true);
    clientConfig.setClientZoneId(clientZoneId);
    SocketStoreClientFactory socketStoreClientFactory = new SocketStoreClientFactory(clientConfig);
    for (Integer nodeId : cluster.getNodeIds()) {
      SocketStoreFactory socketStoreFactory = new ClientRequestExecutorPool(2, 10000, 100000, 1024);
      VoldemortConfig config =
          ServerTestUtils.createServerConfigWithDefs(
              true,
              nodeId,
              TestUtils.createTempDir().getAbsolutePath(),
              cluster,
              stores,
              new Properties());
      VoldemortServer vs =
          ServerTestUtils.startVoldemortServer(socketStoreFactory, config, cluster);
      vservers.put(nodeId, vs);
      socketStoreFactories.put(nodeId, socketStoreFactory);
      Store<ByteArray, byte[], byte[]> store =
          vs.getStoreRepository().getLocalStore(storeDef.getName());
      Node node = cluster.getNodeById(nodeId);

      VectorClock version1 = new VectorClock();
      version1.incrementVersion(0, System.currentTimeMillis());
      VectorClock version2 = version1.incremented(0, System.currentTimeMillis());

      if (node.getZoneId() == clientZoneId) {
        store.put(new ByteArray(bytes1), new Versioned<byte[]>(bytes1, version1), null);
      } else {
        store.put(new ByteArray(bytes1), new Versioned<byte[]>(bytes2, version2), null);
      }
    }

    client = socketStoreClientFactory.getRawStore(storeDef.getName(), null);
  }