Examples of Builder


Examples of com.iviu.gcm.Result.Builder

        String[] responseParts = split(line);
        String token = responseParts[0];
        String value = responseParts[1];
        if (token.equals(TOKEN_MESSAGE_ID))
        {
          Builder builder = new Result.Builder().messageId(value);
          // check for canonical registration id
          line = reader.readLine();
          if (line != null)
          {
            responseParts = split(line);
            token = responseParts[0];
            value = responseParts[1];
            if (token.equals(TOKEN_CANONICAL_REG_ID))
            {
              builder.canonicalRegistrationId(value);
            }
            else
            {
              logger.warning("Received invalid second line from GCM: "
                  + line);
            }
          }

          Result result = builder.build();
          if (logger.isLoggable(Level.FINE))
          {
            logger.fine("Message created succesfully (" + result
                + ")");
          }
View Full Code Here

Examples of com.jcloisterzone.figure.Builder

        builderState = (BuilderState) data;
    }

    @Override
    public void initPlayer(Player player) {
        player.addMeeple(new Builder(game, player));
    }
View Full Code Here

Examples of com.linkedin.helix.PropertyKey.Builder

  {
    String controllerName = CONTROLLER_PREFIX + "_0";
   
    HelixManager manager = _startCMResultMap.get(controllerName)._manager;
    HelixDataAccessor accessor = manager.getHelixDataAccessor();
    Builder kb = accessor.keyBuilder();
    ExternalView ev = accessor.getProperty(kb.externalView(TEST_DB));
    Map<String, LiveInstance> liveinstanceMap = accessor.getChildValuesMap(accessor.keyBuilder().liveInstances());
   
    for(String instanceName : liveinstanceMap.keySet())
    {
      String sessionid = liveinstanceMap.get(instanceName).getSessionId();
      for(String partition : ev.getPartitionSet())
      {
        if(ev.getStateMap(partition).containsKey(instanceName))
        {
          String uuid = UUID.randomUUID().toString();
          Message message = new Message(MessageType.STATE_TRANSITION, uuid);
          boolean rand = new Random().nextInt(10) > 5;
          if(ev.getStateMap(partition).get(instanceName).equals("MASTER"))
          {
            message.setSrcName(manager.getInstanceName());
            message.setTgtName(instanceName);
            message.setMsgState(MessageState.NEW);
            message.setPartitionName(partition);
            message.setResourceName(TEST_DB);
            message.setFromState(rand ? "SLAVE" : "OFFLINE");
            message.setToState(rand ? "MASTER" : "SLAVE");
            message.setTgtSessionId(sessionid);
            message.setSrcSessionId(manager.getSessionId());
            message.setStateModelDef("MasterSlave");
            message.setStateModelFactoryName("DEFAULT");
          }
          else if (ev.getStateMap(partition).get(instanceName).equals("SLAVE"))
          {
            message.setSrcName(manager.getInstanceName());
            message.setTgtName(instanceName);
            message.setMsgState(MessageState.NEW);
            message.setPartitionName(partition);
            message.setResourceName(TEST_DB);
            message.setFromState(rand ? "MASTER" : "OFFLINE");
            message.setToState(rand ? "SLAVE" : "SLAVE");
            message.setTgtSessionId(sessionid);
            message.setSrcSessionId(manager.getSessionId());
            message.setStateModelDef("MasterSlave");
            message.setStateModelFactoryName("DEFAULT");
          }
          accessor.setProperty(accessor.keyBuilder().message(instanceName, message.getMsgId()), message);
        }
      }
    }
    Thread.sleep(3000);
    ExternalView ev2 = accessor.getProperty(kb.externalView(TEST_DB));
    Assert.assertTrue(ev.equals(ev2));
  }
View Full Code Here

Examples of com.mongodb.MongoClientOptions.Builder

   
    HistManData data =new HistManData(loadProperties(model));

    try {

      Builder options = new MongoClientOptions.Builder();

      options.connectTimeout(data.histDBTimeout);

      if(mongoClient==null) {
        mongoClient = new MongoClient(data.histURL, options.build());
      }

      logger.info("trying to connect with database {} in host {}",
          data.histDBName, data.histURL);
View Full Code Here

Examples of com.netflix.astyanax.AstyanaxContext.Builder

        .withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
    }


    public static AstyanaxContext<Keyspace> newContext(String hostString, String keyspace) {
        Builder builder = newBuilder(hostString);
        AstyanaxContext<Keyspace> context = builder.forKeyspace(keyspace).buildKeyspace(ThriftFamilyFactory.getInstance());
        context.start();
        return context;
    }
View Full Code Here

Examples of com.netflix.curator.framework.CuratorFrameworkFactory.Builder

  private static final Logger log = LoggerFactory.getLogger(ZookeeperContext.class);

  public CuratorFramework buildZk(List<String> dnsNames) throws OpsException {
    String connectionString = Joiner.on(",").join(dnsNames);

    Builder builder = CuratorFrameworkFactory.builder();
    builder.connectString(connectionString);
    TimeSpan retryInterval = TimeSpan.FIVE_SECONDS;
    RetryPolicy retryPolicy = new RetryOneTime((int) retryInterval.getTotalMilliseconds());
    builder.retryPolicy(retryPolicy);

    CuratorFramework curatorFramework;
    try {
      curatorFramework = builder.build();
    } catch (IOException e) {
      throw new OpsException("Error building zookeeper connection", e);
    }

    return curatorFramework;
View Full Code Here

Examples of com.netflix.eureka.util.StatusInfo.Builder

    private final PeerAwareInstanceRegistry registry = PeerAwareInstanceRegistry
    .getInstance();

    @GET
    public StatusInfo getStatusInfo() {
        Builder builder = Builder.newBuilder();
        // Add application level status
        StringBuilder upReplicas = new StringBuilder();
        StringBuilder downReplicas = new StringBuilder();

        StringBuilder replicaHostNames = new StringBuilder();
        String myAppName = ApplicationInfoManager.getInstance().getInfo()
        .getAppName();

        for (PeerEurekaNode node : registry.getReplicaNodes()) {
            if (replicaHostNames.length() > 0) {
                replicaHostNames.append(", ");
            }
            replicaHostNames.append(node.getServiceUrl());
            if (isReplicaAvailable(myAppName, node.getServiceUrl())) {
                upReplicas.append(node.getServiceUrl()).append(',');
            } else {
                downReplicas.append(node.getServiceUrl()).append(',');
            }
        }

        builder.add("registered-replicas", replicaHostNames.toString());
        builder.add("available-replicas", upReplicas.toString());
        builder.add("unavailable-replicas", downReplicas.toString());

        return builder.build();
    }
View Full Code Here

Examples of com.ning.http.client.AsyncHttpClientConfig.Builder

        String proxyPort = Play.configuration.getProperty("http.proxyPort", System.getProperty("http.proxyPort"));
        String proxyUser = Play.configuration.getProperty("http.proxyUser", System.getProperty("http.proxyUser"));
        String proxyPassword = Play.configuration.getProperty("http.proxyPassword", System.getProperty("http.proxyPassword"));
        String userAgent = Play.configuration.getProperty("http.userAgent");

        Builder confBuilder = new AsyncHttpClientConfig.Builder();
        if (proxyHost != null) {
            int proxyPortInt = 0;
            try {
                proxyPortInt = Integer.parseInt(proxyPort);
            } catch (NumberFormatException e) {
                Logger.error("Cannot parse the proxy port property '%s'. Check property http.proxyPort either in System configuration or in Play config file.", proxyPort);
                throw new IllegalStateException("WS proxy is misconfigured -- check the logs for details");
            }
            ProxyServer proxy = new ProxyServer(proxyHost, proxyPortInt, proxyUser, proxyPassword);
            confBuilder.setProxyServer(proxy);
        }
        if (userAgent != null) {
            confBuilder.setUserAgent(userAgent);
        }
        // when using raw urls, AHC does not encode the params in url.
        // this means we can/must encode it(with correct encoding) before passing it to AHC
        confBuilder.setUseRawUrl(true);
        httpClient = new AsyncHttpClient(confBuilder.build());
    }
View Full Code Here

Examples of com.opengamma.bbg.cli.BloombergCliOptions.Builder

    BloombergRefDataCollector refDataCollector = new BloombergRefDataCollector(new File(identifiersFile), refDataProvider, new File(dataFieldFile), new File(outputFile));
    refDataCollector.start();
  }

  private static BloombergCliOptions createOptions() {
    Builder builder = new BloombergCliOptions.Builder()
      .withDataFieldsFile(true)
      .withIdentifiers(true)
      .withOutput(true)
      .withHost(true)
      .withPort(false);
    return builder.build();
  }
View Full Code Here

Examples of com.opengamma.engine.value.ValueProperties.Builder

    final Set<String> adjustValues = desiredValue.getConstraints().getValues(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY);
    final Set<String> ageLimitValues = desiredValue.getConstraints().getValues(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY);
    if (adjustValues != null && adjustValues.size() == 1 && ageLimitValues != null && ageLimitValues.size() == 1) {
      return ImmutableSet.of();
    }
    final Builder constraints = desiredValue.getConstraints().copy();
    if (adjustValues == null || adjustValues.isEmpty()) {
      constraints.withoutAny(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY)
          .with(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY, "");
    } else {
      constraints.withoutAny(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY)
          .with(HistoricalTimeSeriesFunctionUtils.ADJUST_PROPERTY, adjustValues.iterator().next());
    }
    if (ageLimitValues == null || ageLimitValues.isEmpty()) {
      constraints.withoutAny(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY)
          .with(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY, HistoricalTimeSeriesFunctionUtils.UNLIMITED_AGE_LIMIT_VALUE);
    } else {
      constraints.withoutAny(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY)
          .with(HistoricalTimeSeriesFunctionUtils.AGE_LIMIT_PROPERTY, ageLimitValues.iterator().next());
    }
    return ImmutableSet.of(new ValueRequirement(ValueRequirementNames.HISTORICAL_TIME_SERIES_LATEST, target.toSpecification(), constraints.get()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.