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.connector.jmx;
 
 
 
 import java.util.List;
 
 import static com.facebook.presto.spi.TupleDomain.withFixedValues;
 import static com.facebook.presto.util.ImmutableCollectors.toImmutableList;
 import static com.facebook.presto.util.Types.checkType;
 import static com.google.common.base.MoreObjects.toStringHelper;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.collect.Iterables.getOnlyElement;
 import static io.airlift.slice.Slices.utf8Slice;
 
 public class JmxSplitManager
         implements ConnectorSplitManager
 {
     private final String connectorId;
     private final NodeManager nodeManager;
 
     @Inject
     public JmxSplitManager(JmxConnectorId jmxConnectorIdNodeManager nodeManager)
     {
         this. = checkNotNull(jmxConnectorId"jmxConnectorId is null").toString();
         this. = checkNotNull(nodeManager"nodeManager is null");
     }
 
     @Override
     {
         checkNotNull(tupleDomain"tupleDomain is null");
         JmxTableHandle jmxTableHandle = checkType(tableJmxTableHandle.class"table");
 
         List<ConnectorPartitionpartitions = ImmutableList.<ConnectorPartition>of(new JmxPartition(jmxTableHandletupleDomain));
         return new ConnectorPartitionResult(partitionstupleDomain);
     }
 
     @Override
     {
         checkNotNull(partitions"partitions is null");
         if (partitions.isEmpty()) {
             return new FixedSplitSource(, ImmutableList.of());
         }
 
         JmxPartition jmxPartition = checkType(getOnlyElement(partitions), JmxPartition.class"partition");
         JmxTableHandle tableHandle = jmxPartition.getTableHandle();
         TupleDomain<ColumnHandlepredicate = jmxPartition.getPredicate();
 
         //TODO is there a better way to get the node column?
         JmxColumnHandle nodeColumnHandle = tableHandle.getColumns().get(0);
 
         ImmutableList<ConnectorSplitsplits = .getActiveNodes()
                 .stream()
                 .filter(node -> {
                             TupleDomain<ColumnHandleexactNodeMatch = withFixedValues(ImmutableMap.of(nodeColumnHandleutf8Slice(node.getNodeIdentifier())));
                             return predicate.overlaps(exactNodeMatch);
                         }
                 )
                 .map(node -> new JmxSplit(tableHandle, ImmutableList.of(node.getHostAndPort())))
                 .collect(toImmutableList());
 
         return new FixedSplitSource(splits);
     }
 
     public static class JmxPartition
             implements ConnectorPartition
     {
         private final JmxTableHandle tableHandle;
         private final TupleDomain<ColumnHandlepredicate;
 
         public JmxPartition(JmxTableHandle tableHandleTupleDomain<ColumnHandlepredicate)
         {
            this. = checkNotNull(tableHandle"tableHandle is null");
            this. = checkNotNull(predicate"predicate is null");
        }
        public JmxTableHandle getTableHandle()
        {
            return ;
        }
        public TupleDomain<ColumnHandlegetPredicate()
        {
            return ;
        }
        @Override
        public String getPartitionId()
        {
            return "jmx";
        }
        @Override
        public TupleDomain<ColumnHandlegetTupleDomain()
        {
            return TupleDomain.all();
        }
        @Override
        public String toString()
        {
            return toStringHelper(this)
                    .add("tableHandle")
                    .add("predicate")
                    .toString();
        }
    }
New to GrepCode? Check out our FAQ X