All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.clickzetta.platform.test.CZLocalCluster Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.clickzetta.platform.test;

import com.google.common.annotations.VisibleForTesting;
import cz.proto.ingestion.Ingestion;
import io.grpc.BindableService;

import java.util.ArrayList;
import java.util.List;

import static com.clickzetta.platform.common.Constant.CLOSEABLE_INTERNAL_DEFAULT_WAIT_TIME_MS;

@VisibleForTesting
public abstract class CZLocalCluster extends CZTestBase {

  private int routerPort = 10100;
  private int controllerPort = 10186;
  private int[] workerPort = {10188, 10189};

  static {
    CLOSEABLE_INTERNAL_DEFAULT_WAIT_TIME_MS = 1000;
  }

  @Override
  public boolean routerModeEnable() {
    return false;
  }

  @Override
  public Ingestion.HostPortTuple getRouterTuple() {
    return Ingestion.HostPortTuple.newBuilder()
        .setHost("localhost")
        .setPort(routerPort).build();
  }

  @Override
  public Ingestion.HostPortTuple getControllerTuple() {
    return Ingestion.HostPortTuple.newBuilder()
        .setHost("localhost")
        .setPort(controllerPort).build();
  }

  @Override
  public List getWorkerTuples() {
    List list = new ArrayList<>();
    for (int port : workerPort) {
      list.add(Ingestion.HostPortTuple.newBuilder()
          .setHost("localhost")
          .setPort(port).build());
    }
    return list;
  }

  @Override
  public List getRouterServices() {
    List bindableServices = new ArrayList<>();
    bindableServices.add(new BaseIgsRouter(getControllerTuple()));
    return bindableServices;
  }

  @Override
  public List getControllerServices() {
    List bindableServices = new ArrayList<>();
    BaseIgsController controllerV1 = new BaseIgsController(() -> getHostPortTupleWithCache(ServerName.WORKER));
    BaseIgsControllerV2 controllerV2 = new BaseIgsControllerV2(() -> getHostPortTupleWithCache(ServerName.WORKER));
    controllerV1.setControllerV2(controllerV2);
    bindableServices.add(controllerV1);
    bindableServices.add(controllerV2);
    return bindableServices;
  }

  @Override
  public List getWorkerServices() {
    List bindableServices = new ArrayList<>();
    bindableServices.add(new BaseIgsWorker());
    bindableServices.add(new BaseIgsWorkerV2());
    return bindableServices;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy