Ejemplo n.º 1
0
  @After
  public void teardown() {
    adminClient.close();
    server.stop();

    factory.close();
  }
Ejemplo n.º 2
0
  @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);
  }
  @Override
  public void run() {

    StoreDefinition storeDef =
        StoreDefinitionUtils.getStoreDefinitionWithName(
            storeClientFactory.getStoreDefs(), storeName);
    String serializerInfoXml = CoordinatorUtils.constructSerializerInfoXml(storeDef);
    try {
      writeResponse(serializerInfoXml.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
      logger.error(e);
    }
  }
Ejemplo n.º 4
0
  @Before
  public void setup() throws IOException {

    Properties props = new Properties();
    props.put("enable.quota.limiting", "true");
    server =
        ServerTestUtils.startStandAloneVoldemortServer(
            props, "test/common/voldemort/config/single-store.xml");

    adminClient =
        new AdminClient(
            server.getMetadataStore().getCluster(), new AdminClientConfig(), new ClientConfig());
    String bootStrapUrl =
        "tcp://"
            + server.getIdentityNode().getHost()
            + ":"
            + server.getIdentityNode().getSocketPort();
    factory = new SocketStoreClientFactory(new ClientConfig().setBootstrapUrls(bootStrapUrl));
    storeClient = factory.getStoreClient("test");
  }