Exemplo n.º 1
0
 public SocketStore(String name, SocketDestination dest, SocketPool socketPool, boolean reroute) {
   this.name = Utils.notNull(name);
   this.pool = Utils.notNull(socketPool);
   this.destination = dest;
   this.requestFormat = requestFormatFactory.getRequestFormat(dest.getRequestFormatType());
   this.reroute = reroute;
 }
Exemplo n.º 2
0
 public StatusServlet(VoldemortServer server, VelocityEngine engine) {
   this.server = Utils.notNull(server);
   this.velocityEngine = Utils.notNull(engine);
   this.abstractSocketService = (AbstractSocketService) server.getService(ServiceType.SOCKET);
   try {
     this.myMachine = InetAddress.getLocalHost().getHostName();
   } catch (UnknownHostException e) {
     myMachine = "unknown";
   }
 }
Exemplo n.º 3
0
 public SocketStore(
     String storeName,
     long timeoutMs,
     SocketDestination dest,
     ClientRequestExecutorPool pool,
     RequestRoutingType requestRoutingType) {
   this.storeName = Utils.notNull(storeName);
   this.timeoutMs = timeoutMs;
   this.pool = Utils.notNull(pool);
   this.destination = dest;
   this.requestFormat = requestFormatFactory.getRequestFormat(dest.getRequestFormatType());
   this.requestRoutingType = requestRoutingType;
 }
Exemplo n.º 4
0
 @Override
 public void init() throws ServletException {
   super.init();
   this.server =
       (VoldemortServer)
           Utils.notNull(
               getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY));
   this.velocityEngine =
       (VelocityEngine)
           Utils.notNull(
               getServletContext()
                   .getAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY));
 }
Exemplo n.º 5
0
  public StreamingSlopPusherJob(
      StoreRepository storeRepo,
      MetadataStore metadataStore,
      FailureDetector failureDetector,
      VoldemortConfig voldemortConfig,
      ScanPermitWrapper repairPermits) {
    this.storeRepo = storeRepo;
    this.metadataStore = metadataStore;
    this.failureDetector = failureDetector;
    this.voldemortConfig = voldemortConfig;
    this.repairPermits = Utils.notNull(repairPermits);
    this.readThrottler = new EventThrottler(voldemortConfig.getSlopMaxReadBytesPerSec());
    this.adminClient = null;
    this.consumerResults = Lists.newArrayList();
    this.zoneMapping = Maps.newHashMap();
    this.consumerExecutor =
        Executors.newCachedThreadPool(
            new ThreadFactory() {

              public Thread newThread(Runnable r) {
                Thread thread = new Thread(r);
                thread.setName("slop-pusher");
                return thread;
              }
            });
  }
Exemplo n.º 6
0
 public void initVelocity(ServletConfig config) {
   this.velocityEngine =
       (VelocityEngine)
           Utils.notNull(
               config
                   .getServletContext()
                   .getAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY));
 }
Exemplo n.º 7
0
 private List<ReadOnlyStorageEngine> getReadOnlyStores(VoldemortServer server) {
   StorageService storage = (StorageService) Utils.notNull(server).getService(ServiceType.STORAGE);
   List<ReadOnlyStorageEngine> l = Lists.newArrayList();
   for (StorageEngine<ByteArray, byte[]> engine :
       storage.getStoreRepository().getStorageEnginesByClass(ReadOnlyStorageEngine.class)) {
     l.add((ReadOnlyStorageEngine) engine);
   }
   return l;
 }
Exemplo n.º 8
0
  public BdbStorageEngine(String name, Environment environment, Database database) {
    this.name = Utils.notNull(name);
    this.bdbDatabase = Utils.notNull(database);
    this.environment = Utils.notNull(environment);
    this.versionedSerializer = new VersionedSerializer<byte[]>(new IdentitySerializer());
    this.versionSerializer =
        new Serializer<Version>() {

          public byte[] toBytes(Version object) {
            return ((VectorClock) object).toBytes();
          }

          public Version toObject(byte[] bytes) {
            return versionedSerializer.getVersion(bytes);
          }
        };
    this.isOpen = new AtomicBoolean(true);
  }
Exemplo n.º 9
0
  protected RoutedStore(
      String name,
      Map<Integer, Store<ByteArray, byte[], byte[]>> innerStores,
      Cluster cluster,
      StoreDefinition storeDef,
      boolean repairReads,
      TimeoutConfig timeoutConfig,
      FailureDetector failureDetector,
      Time time) {
    if (storeDef.getRequiredReads() < 1)
      throw new IllegalArgumentException(
          "Cannot have a storeDef.getRequiredReads() number less than 1.");
    if (storeDef.getRequiredWrites() < 1)
      throw new IllegalArgumentException(
          "Cannot have a storeDef.getRequiredWrites() number less than 1.");
    if (storeDef.getPreferredReads() < storeDef.getRequiredReads())
      throw new IllegalArgumentException(
          "storeDef.getPreferredReads() must be greater or equal to storeDef.getRequiredReads().");
    if (storeDef.getPreferredWrites() < storeDef.getRequiredWrites())
      throw new IllegalArgumentException(
          "storeDef.getPreferredWrites() must be greater or equal to storeDef.getRequiredWrites().");
    if (storeDef.getPreferredReads() > innerStores.size())
      throw new IllegalArgumentException(
          "storeDef.getPreferredReads() is larger than the total number of nodes!");
    if (storeDef.getPreferredWrites() > innerStores.size())
      throw new IllegalArgumentException(
          "storeDef.getPreferredWrites() is larger than the total number of nodes!");

    this.name = name;
    this.innerStores =
        new ConcurrentHashMap<Integer, Store<ByteArray, byte[], byte[]>>(innerStores);
    this.repairReads = repairReads;
    this.readRepairer = new ReadRepairer<ByteArray, byte[]>();
    this.timeoutConfig = timeoutConfig;
    this.time = Utils.notNull(time);
    this.storeDef = storeDef;
    this.failureDetector = failureDetector;
    this.routingStrategy = new RoutingStrategyFactory().updateRoutingStrategy(storeDef, cluster);
  }
Exemplo n.º 10
0
  public StreamingSlopPusherJob(
      StoreRepository storeRepo,
      MetadataStore metadataStore,
      FailureDetector failureDetector,
      VoldemortConfig voldemortConfig,
      Semaphore repairPermits) {
    this.storeRepo = storeRepo;
    this.metadataStore = metadataStore;
    this.failureDetector = failureDetector;
    this.voldemortConfig = voldemortConfig;
    this.repairPermits = Utils.notNull(repairPermits);

    this.cluster = metadataStore.getCluster();
    this.slopQueues =
        new ConcurrentHashMap<Integer, SynchronousQueue<Versioned<Slop>>>(
            cluster.getNumberOfNodes());
    this.consumerExecutor =
        Executors.newFixedThreadPool(
            cluster.getNumberOfNodes(),
            new ThreadFactory() {

              public Thread newThread(Runnable r) {
                Thread thread = new Thread(r);
                thread.setName("slop-pusher");
                return thread;
              }
            });

    this.readThrottler = new EventThrottler(voldemortConfig.getSlopMaxReadBytesPerSec());
    this.adminClient = null;
    this.consumerResults = Lists.newArrayList();
    this.attemptedByNode = new ConcurrentHashMap<Integer, Long>(cluster.getNumberOfNodes());
    this.succeededByNode = new ConcurrentHashMap<Integer, Long>(cluster.getNumberOfNodes());

    this.zoneMapping = Maps.newHashMap();
  }
Exemplo n.º 11
0
 public synchronized void removeNode(Node node) {
   Utils.notNull(node);
   nodes.remove(node);
 }
Exemplo n.º 12
0
 public synchronized void addNode(Node node) {
   Utils.notNull(node);
   nodes.add(node);
 }
Exemplo n.º 13
0
 /**
  * Assigns a list of nodes in the cluster represented by this failure detector configuration.
  *
  * @param nodes Collection of Node instances, usually determined from the Cluster; must be
  *     non-null
  */
 @Deprecated
 public synchronized FailureDetectorConfig setNodes(Collection<Node> nodes) {
   Utils.notNull(nodes);
   this.nodes = new HashSet<Node>(nodes);
   return this;
 }
Exemplo n.º 14
0
 /**
  * Assigns a cluster which determines the source of truth for the topology
  *
  * @param cluster The Cluster object retrieved during bootstrap; must be non-null
  */
 public FailureDetectorConfig setCluster(Cluster cluster) {
   Utils.notNull(cluster);
   this.cluster = cluster;
   return this;
 }
Exemplo n.º 15
0
 /**
  * Assigns the list of Java Exception types that are considered catastrophic. Some FailureDetector
  * implementations may not mark a given node as unavailable on each and every call to
  * recordException. Instead they may apply logic to determine if such an exception should cause
  * the node to be marked as unavailable. However, the list of so-called catastrophic errors
  * provides such FailureDetector implementations a hint that receipt of such errors should cause
  * the node to be marked as unavailable immediately, regardless of other logic.
  *
  * <p><b>Note</b>: this is only used by the {@link ThresholdFailureDetector} implementation.
  *
  * @param catastrophicErrorTypes List of fully-qualified Java Exception class names against which
  *     to check the exception provided to recordException; this list should be immutable and
  *     non-null
  * @see ThresholdFailureDetector
  * @see VoldemortConfig#getFailureDetectorCatastrophicErrorTypes
  * @see ClientConfig#getFailureDetectorCatastrophicErrorTypes
  */
 public FailureDetectorConfig setCatastrophicErrorTypes(List<String> catastrophicErrorTypes) {
   this.catastrophicErrorTypes = Utils.notNull(catastrophicErrorTypes);
   return this;
 }
Exemplo n.º 16
0
 /**
  * Assigns the fully-qualified class name of the FailureDetector implementation.
  *
  * @param implementationClassName Class name to instantiate for the FailureDetector
  * @see VoldemortConfig#getFailureDetectorImplementation
  * @see ClientConfig#getFailureDetectorImplementation
  */
 public FailureDetectorConfig setImplementationClassName(String implementationClassName) {
   this.implementationClassName = Utils.notNull(implementationClassName);
   return this;
 }
Exemplo n.º 17
0
 /**
  * Set the tier at which routing occurs. Client-side routing occurs on the client, and server-side
  * routing on the server.
  *
  * <p>NOTE : Server side routing is not used, as yet. The java client only supports client-side
  * routing.
  *
  * @param routingTier The routing tier to use for routing requests
  */
 public ClientConfig setRoutingTier(RoutingTier routingTier) {
   this.routingTier = Utils.notNull(routingTier);
   return this;
 }
Exemplo n.º 18
0
 /**
  * Set the request format type used for network communications (for example protocol buffers)
  *
  * @param requestFormatType The type of the network protocol
  */
 public ClientConfig setRequestFormatType(RequestFormatType requestFormatType) {
   this.requestFormatType = Utils.notNull(requestFormatType);
   return this;
 }
Exemplo n.º 19
0
 /**
  * Set the bootstrap urls from which to attempt a connection
  *
  * @param bootstrapUrls The urls to bootstrap from
  */
 public ClientConfig setBootstrapUrls(String... bootstrapUrls) {
   this.bootstrapUrls = Arrays.asList(Utils.notNull(bootstrapUrls));
   if (this.bootstrapUrls.size() <= 0)
     throw new IllegalArgumentException("Must provide at least one bootstrap URL.");
   return this;
 }
Exemplo n.º 20
0
 public FailureDetectorConfig setStoreVerifier(StoreVerifier storeVerifier) {
   this.storeVerifier = Utils.notNull(storeVerifier);
   return this;
 }
Exemplo n.º 21
0
 public ReadOnlyStoreManagementServlet(VoldemortServer server, VelocityEngine engine) {
   this.stores = getReadOnlyStores(server);
   this.velocityEngine = Utils.notNull(engine);
   setFetcherClass(server);
 }
Exemplo n.º 22
0
 public FailureDetectorConfig setTime(Time time) {
   this.time = Utils.notNull(time);
   return this;
 }
Exemplo n.º 23
0
 /** Set the SerializerFactory used to serialize and deserialize values */
 public ClientConfig setSerializerFactory(SerializerFactory serializerFactory) {
   this.serializerFactory = Utils.notNull(serializerFactory);
   return this;
 }