Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.facebook.presto.discovery;
 
 
 
 import java.util.List;
 import java.util.Set;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static io.airlift.configuration.ConfigurationModule.bindConfig;
 import static io.airlift.discovery.client.DiscoveryBinder.discoveryBinder;
 import static io.airlift.json.JsonCodecBinder.jsonCodecBinder;
 
 public class EmbeddedDiscoveryModule
         extends AbstractConfigurationAwareModule
 {
     @Override
     protected void setup(Binder binder)
     {
         if (!buildConfigObject(EmbeddedDiscoveryConfig.class).isEnabled()) {
             return;
         }
 
         bindConfig(binder).to(DiscoveryConfig.class);
         binder.bind(ServiceResource.class).in(.);
 
         discoveryBinder(binder).bindHttpAnnouncement("discovery");
 
         jsonCodecBinder(binder).bindJsonCodec(Service.class);
         jsonCodecBinder(binder).bindListJsonCodec(Service.class);
 
         binder.bind(ServiceSelector.class).to(DiscoveryServiceSelector.class);
         binder.bind(StaticStore.class).to(EmptyStaticStore.class);
 
         binder.bind(DynamicAnnouncementResource.class).in(.);
         binder.bind(DynamicStore.class).to(ReplicatedDynamicStore.class).in(.);
         binder.install(new ReplicatedStoreModule("dynamic"ForDynamicStore.classInMemoryStore.class));
     }
 
     private static class DiscoveryServiceSelector
             implements ServiceSelector
     {
         private final NodeInfo nodeInfo;
         private final ServiceInventory inventory;
 
         @Inject
         public DiscoveryServiceSelector(NodeInfo nodeInfoServiceInventory inventory)
         {
             this. = checkNotNull(nodeInfo"nodeInfo is null");
             this. = checkNotNull(inventory"inventory is null");
         }
 
         @Override
         public String getType()
         {
             return "discovery";
         }
 
         @Override
         public String getPool()
         {
             return .getPool();
         }
 
         @Override
         public List<ServiceDescriptorselectAllServices()
        {
            return ImmutableList.copyOf(.getServiceDescriptors(getType()));
        }
    }
    private static class EmptyStaticStore
            implements StaticStore
    {
        @Override
        public void put(Service service)
        {
            throw new UnsupportedOperationException();
        }
        @Override
        public void delete(Id<Serviceid)
        {
            throw new UnsupportedOperationException();
        }
        @Override
        public Set<ServicegetAll()
        {
            return ImmutableSet.of();
        }
        @Override
        public Set<Serviceget(String type)
        {
            return ImmutableSet.of();
        }
        @Override
        public Set<Serviceget(String typeString pool)
        {
            return ImmutableSet.of();
        }
    }
New to GrepCode? Check out our FAQ X