Beispiel #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;
 }
Beispiel #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";
   }
 }
Beispiel #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;
 }
Beispiel #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));
 }
  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;
              }
            });
  }
Beispiel #6
0
 public void initVelocity(ServletConfig config) {
   this.velocityEngine =
       (VelocityEngine)
           Utils.notNull(
               config
                   .getServletContext()
                   .getAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY));
 }
Beispiel #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;
 }
Beispiel #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);
  }
Beispiel #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);
  }
  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();
  }
 public synchronized void removeNode(Node node) {
   Utils.notNull(node);
   nodes.remove(node);
 }
 public synchronized void addNode(Node node) {
   Utils.notNull(node);
   nodes.add(node);
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #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;
 }
 public FailureDetectorConfig setStoreVerifier(StoreVerifier storeVerifier) {
   this.storeVerifier = Utils.notNull(storeVerifier);
   return this;
 }
Beispiel #21
0
 public ReadOnlyStoreManagementServlet(VoldemortServer server, VelocityEngine engine) {
   this.stores = getReadOnlyStores(server);
   this.velocityEngine = Utils.notNull(engine);
   setFetcherClass(server);
 }
 public FailureDetectorConfig setTime(Time time) {
   this.time = Utils.notNull(time);
   return this;
 }
Beispiel #23
0
 /** Set the SerializerFactory used to serialize and deserialize values */
 public ClientConfig setSerializerFactory(SerializerFactory serializerFactory) {
   this.serializerFactory = Utils.notNull(serializerFactory);
   return this;
 }