Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
This software is licensed to you under the Apache License, Version 2.0 (the "Apache License"). LinkedIn's contributions are made under the Apache License. If you contribute to the Software, the contributions will be deemed to have been made under the Apache License, unless you expressly indicate otherwise. Please do not make any contributions that would be inconsistent with the Apache License. You may obtain a copy of the Apache License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, this software distributed under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for the specific language governing permissions and limitations for the software governed under the Apache License. © 2012 LinkedIn Corp. All Rights Reserved.
package com.senseidb.federated.broker.proxy;
import  com.linkedin.norbert.javacompat.cluster.ClusterClient;
import  com.linkedin.norbert.javacompat.network.PartitionedLoadBalancerFactory;
import  com.linkedin.norbert.javacompat.network.PartitionedNetworkClient;
public class SenseiBrokerProxy extends SenseiBroker implements BrokerProxy {
  private final static Logger logger = Logger.getLogger(SenseiBrokerProxy.class);
  private static PartitionedLoadBalancerFactory balancerFactory = new SenseiPartitionedLoadBalancerFactory(50);  
  private final Timer scatterTimer;
  private final Meter ErrorMeter;
  public SenseiBrokerProxy(PartitionedNetworkClient<StringnetworkClient, ClusterClient clusterClientboolean allowPartialMerge) {
    super(networkClientclusterClientallowPartialMerge);
    MetricName scatterMetricName = new MetricName(SenseiBrokerProxy.class,"scatter-time");
     = MetricFactory.newTimer(scatterMetricName..);
    MetricName errorMetricName = new MetricName(SenseiBrokerProxy.class,"error-meter");
     = MetricFactory.newMeter(errorMetricName"errors",.);
  }
  public static SenseiBrokerProxy valueOf(Configuration senseiConfigurationMap<StringStringoverrideProperties) {
    BrokerProxyConfig brokerProxyConfig = new BrokerProxyConfig(senseiConfigurationoverrideProperties);
    brokerProxyConfig.init();
    SenseiBrokerProxy ret = new SenseiBrokerProxy(brokerProxyConfig.getNetworkClient(), brokerProxyConfig.getClusterClient(), true);
    return ret;
  }
  public List<SenseiResultdoQuery(final SenseiRequest senseiRequest) {
    final List<SenseiResultresultList = new ArrayList<SenseiResult>();
    
    try {
      resultList.addAll(.time(new Callable<List<SenseiResult>>() {
        @Override
        public List<SenseiResultcall() throws Exception {
          return doCall(senseiRequest);
        }
      }));
    } catch (Exception e) {
      .mark();
      SenseiResult emptyResult = getEmptyResultInstance();
      .error("Error running scatter/gather"e);
      emptyResult.addError(new SenseiError("Error gathering the results" + e.getMessage(), .));
      return Arrays.asList(emptyResult);
    }
    return resultList;
  }
New to GrepCode? Check out our FAQ X