Java Code Examples for org.apache.commons.configuration.Configuration#getLong()

The following examples show how to use org.apache.commons.configuration.Configuration#getLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BitsyGraph.java    From bitsy with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor with a Configuration object with String dbPath, boolean allowFullGraphScans, long txLogThreshold and double reorgFactor
 */
public BitsyGraph(Configuration configuration) {
    this(Paths.get(configuration.getString(DB_PATH_KEY)),
            configuration.getBoolean(ALLOW_FULL_GRAPH_SCANS_KEY, Boolean.TRUE),
            configuration.getLong(TX_LOG_THRESHOLD_KEY, DEFAULT_TX_LOG_THRESHOLD),
            configuration.getDouble(REORG_FACTOR_KEY, DEFAULT_REORG_FACTOR),
            configuration.getBoolean(CREATE_DIR_IF_MISSING_KEY, false));
    String isoLevelStr = configuration.getString(DEFAULT_ISOLATION_LEVEL_KEY);
    if (isoLevelStr != null) {
            setDefaultIsolationLevel(BitsyIsolationLevel.valueOf(isoLevelStr));
    }
    String vertexIndices = configuration.getString(VERTEX_INDICES_KEY);
    if (vertexIndices != null) {
            createIndices(Vertex.class, vertexIndices);
    }
    String edgeIndices = configuration.getString(EDGE_INDICES_KEY);
    if (edgeIndices != null) {
            createIndices(Edge.class, edgeIndices);
    }
    this.origConfig = configuration;
}
 
Example 2
Source File: BlazeGraph.java    From tinkerpop3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Construct an instance using the supplied configuration.
 */
protected BlazeGraph(final Configuration config) {
    this.config = config;
    
    this.vf = Optional.ofNullable((BlazeValueFactory) 
                            config.getProperty(Options.VALUE_FACTORY))
                      .orElse(BlazeValueFactory.INSTANCE);
    
    final long listIndexFloor = config.getLong(
            Options.LIST_INDEX_FLOOR, System.currentTimeMillis());
    this.vpIdFactory = new AtomicLong(listIndexFloor);
    
    this.maxQueryTime = config.getInt(Options.MAX_QUERY_TIME, 0);
    
    this.sparqlLogMax = config.getInt(Options.SPARQL_LOG_MAX, 
                                      Options.DEFAULT_SPARQL_LOG_MAX);
    
    this.TYPE = vf.type();
    this.VALUE = vf.value();
    this.LI_DATATYPE = vf.liDatatype();
    
    this.sparql = new SparqlGenerator(vf);
    this.transforms = new Transforms();
}
 
Example 3
Source File: MigrationProgressService.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Inject
public MigrationProgressService(Configuration configuration, GraphDBMigrator migrator) {
    this.migrator      = migrator;
    this.cacheValidity = (configuration != null) ? configuration.getLong(MIGRATION_QUERY_CACHE_TTL, DEFAULT_CACHE_TTL_IN_SECS) : DEFAULT_CACHE_TTL_IN_SECS;

    this.zipFileBasedMigrationImport = isZipFileBasedMigrationEnabled();
    initConditionallyZipFileBasedMigrator();
}
 
Example 4
Source File: ShortestDistanceVertexProgram.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
@Override
public void loadState(final Graph graph, final Configuration configuration) {
    maxDepth = configuration.getInt(MAX_DEPTH);
    seed = configuration.getLong(SEED);
    weightProperty = configuration.getString(WEIGHT_PROPERTY, "distance");
    incidentMessageScope = MessageScope.Local.of(__::inE, (msg, edge) -> msg + edge.<Integer>value(weightProperty));
    log.debug("Loaded maxDepth={}", maxDepth);
}
 
Example 5
Source File: KafkaNotification.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a KafkaNotification.
 *
 * @param applicationProperties  the application properties used to configure Kafka
 *
 * @throws AtlasException if the notification interface can not be created
 */
@Inject
public KafkaNotification(Configuration applicationProperties) throws AtlasException {
    super(applicationProperties);
    Configuration subsetConfiguration =
            ApplicationProperties.getSubsetConfiguration(applicationProperties, PROPERTY_PREFIX);
    properties = ConfigurationConverter.getProperties(subsetConfiguration);
    //override to store offset in kafka
    //todo do we need ability to replay?

    //Override default configs
    properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG,
            "org.apache.kafka.common.serialization.StringSerializer");
    properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
            "org.apache.kafka.common.serialization.StringSerializer");
    properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG,
            "org.apache.kafka.common.serialization.StringDeserializer");
    properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
            "org.apache.kafka.common.serialization.StringDeserializer");
    properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");

    pollTimeOutMs = subsetConfiguration.getLong("poll.timeout.ms", 1000);
    boolean oldApiCommitEnbleFlag = subsetConfiguration.getBoolean("auto.commit.enable",false);
    //set old autocommit value if new autoCommit property is not set.
    properties.put("enable.auto.commit", subsetConfiguration.getBoolean("enable.auto.commit", oldApiCommitEnbleFlag));
    properties.put("session.timeout.ms", subsetConfiguration.getString("session.timeout.ms", "30000"));

}
 
Example 6
Source File: StatsSender.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
public void maybeSendStats(Window parent, Configuration configuration, Services services, String olvVersion) {
  if (configuration.getBoolean(SEND_STATS, false)) {
    final long now = System.currentTimeMillis();
    final long interval = 10L * 24 * 60 * 60 * 1000;

    if (!configuration.containsKey(NEXT_STATS_SEND_DATE)) {
      configuration.setProperty(NEXT_STATS_SEND_DATE, now + interval);
    }

    final long nextSendDate = configuration.getLong(NEXT_STATS_SEND_DATE);
    LOGGER.info("Next stats send will occur in: " + new Date(nextSendDate));

    if (now > nextSendDate) {
      configuration.setProperty(NEXT_STATS_SEND_DATE, (now + interval));
      final boolean notifyAboutStats = configuration.getBoolean(ConfKeys.SEND_STATS_NOTIFY, false);
      final Map<String, Long> stats = services.getStatsService().getStats();
      final String uuid = configuration.getString(UUID, "");
      final String javaVersion = System.getProperty("java.version", "");

      if (notifyAboutStats) {
        showDialog(parent,
          stats,
          () -> scheduleSend(services, olvVersion, stats, uuid, javaVersion),
          () -> configuration.setProperty(ConfKeys.SEND_STATS_NOTIFY, false));
      } else {
        scheduleSend(services, olvVersion, stats, uuid, javaVersion);
      }
    }
  }
}
 
Example 7
Source File: AccumuloConnectionUtils.java    From cognition with Apache License 2.0 5 votes vote down vote up
public static AccumuloConnectionConfig extractConnectionConfiguration(Configuration conf) {
  AccumuloConnectionConfig config = new AccumuloConnectionConfig();
  config.instance = conf.getString(INSTANCE);
  config.zooServers = conf.getString(ZOO_SERVERS);
  config.user = conf.getString(USER);
  config.key = conf.getString(KEY);
  config.maxMem = conf.getLong(MAX_MEM, MAX_MEM_DEFAULT);
  config.maxLatency = conf.getLong(MAX_LATENCY, MAX_LATENCY_DEFAULT);
  config.maxWriteThreads = conf.getInt(MAX_WRITE_THREADS, MAX_WRITE_THREADS_DEFAULT);
  return config;
}
 
Example 8
Source File: LocalStormDoTask.java    From incubator-samoa with Apache License 2.0 5 votes vote down vote up
/**
 * The main method.
 * 
 * @param args
 *          the arguments
 */
public static void main(String[] args) {

  List<String> tmpArgs = new ArrayList<String>(Arrays.asList(args));

  int numWorker = StormSamoaUtils.numWorkers(tmpArgs);

  args = tmpArgs.toArray(new String[0]);

  // convert the arguments into Storm topology
  StormTopology stormTopo = StormSamoaUtils.argsToTopology(args);
  String topologyName = stormTopo.getTopologyName();

  Config conf = new Config();
  // conf.putAll(Utils.readStormConfig());
  conf.setDebug(false);

  // local mode
  conf.setMaxTaskParallelism(numWorker);

  backtype.storm.LocalCluster cluster = new backtype.storm.LocalCluster();
  cluster.submitTopology(topologyName, conf, stormTopo.getStormBuilder().createTopology());

  // Read local mode execution duration from property file
  Configuration stormConfig = StormSamoaUtils.getPropertyConfig(LocalStormDoTask.SAMOA_STORM_PROPERTY_FILE_LOC);
  long executionDuration= stormConfig.getLong(LocalStormDoTask.EXECUTION_DURATION_KEY);
  backtype.storm.utils.Utils.sleep(executionDuration * 1000);

  cluster.killTopology(topologyName);
  cluster.shutdown();

}
 
Example 9
Source File: BaseBrokerRequestHandler.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public BaseBrokerRequestHandler(Configuration config, RoutingManager routingManager,
    AccessControlFactory accessControlFactory, QueryQuotaManager queryQuotaManager, BrokerMetrics brokerMetrics,
    ZkHelixPropertyStore<ZNRecord> propertyStore) {
  _config = config;
  _routingManager = routingManager;
  _accessControlFactory = accessControlFactory;
  _queryQuotaManager = queryQuotaManager;
  _brokerMetrics = brokerMetrics;

  _enableCaseInsensitive = _config.getBoolean(CommonConstants.Helix.ENABLE_CASE_INSENSITIVE_KEY, false);
  if (_enableCaseInsensitive) {
    _tableCache = new TableCache(propertyStore);
  } else {
    _tableCache = null;
  }
  _defaultHllLog2m = _config
      .getInt(CommonConstants.Helix.DEFAULT_HYPERLOGLOG_LOG2M_KEY, CommonConstants.Helix.DEFAULT_HYPERLOGLOG_LOG2M);

  _enableQueryLimitOverride = _config.getBoolean(Broker.CONFIG_OF_ENABLE_QUERY_LIMIT_OVERRIDE, false);

  _brokerId = config.getString(Broker.CONFIG_OF_BROKER_ID, getDefaultBrokerId());
  _brokerTimeoutMs = config.getLong(Broker.CONFIG_OF_BROKER_TIMEOUT_MS, Broker.DEFAULT_BROKER_TIMEOUT_MS);
  _queryResponseLimit =
      config.getInt(Broker.CONFIG_OF_BROKER_QUERY_RESPONSE_LIMIT, Broker.DEFAULT_BROKER_QUERY_RESPONSE_LIMIT);
  _queryLogLength = config.getInt(Broker.CONFIG_OF_BROKER_QUERY_LOG_LENGTH, Broker.DEFAULT_BROKER_QUERY_LOG_LENGTH);
  _queryLogRateLimiter = RateLimiter.create(config.getDouble(Broker.CONFIG_OF_BROKER_QUERY_LOG_MAX_RATE_PER_SECOND,
      Broker.DEFAULT_BROKER_QUERY_LOG_MAX_RATE_PER_SECOND));
  _numDroppedLog = new AtomicInteger(0);
  _numDroppedLogRateLimiter = RateLimiter.create(1.0);

  LOGGER
      .info("Broker Id: {}, timeout: {}ms, query response limit: {}, query log length: {}, query log max rate: {}qps",
          _brokerId, _brokerTimeoutMs, _queryResponseLimit, _queryLogLength, _queryLogRateLimiter.getRate());
}
 
Example 10
Source File: KafkaNotification.java    From atlas with Apache License 2.0 4 votes vote down vote up
/**
 * Construct a KafkaNotification.
 *
 * @param applicationProperties  the application properties used to configure Kafka
 *
 * @throws AtlasException if the notification interface can not be created
 */
@Inject
public KafkaNotification(Configuration applicationProperties) throws AtlasException {
    super(applicationProperties);

    LOG.info("==> KafkaNotification()");

    Configuration kafkaConf = ApplicationProperties.getSubsetConfiguration(applicationProperties, PROPERTY_PREFIX);

    properties             = ConfigurationConverter.getProperties(kafkaConf);
    pollTimeOutMs          = kafkaConf.getLong("poll.timeout.ms", 1000);
    consumerClosedErrorMsg = kafkaConf.getString("error.message.consumer_closed", DEFAULT_CONSUMER_CLOSED_ERROR_MESSAGE);

    //Override default configs
    properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
    properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
    properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
    properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
    properties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");

    boolean oldApiCommitEnableFlag = kafkaConf.getBoolean("auto.commit.enable", false);

    //set old autocommit value if new autoCommit property is not set.
    properties.put("enable.auto.commit", kafkaConf.getBoolean("enable.auto.commit", oldApiCommitEnableFlag));
    properties.put("session.timeout.ms", kafkaConf.getString("session.timeout.ms", "30000"));

    if(applicationProperties.getBoolean(TLS_ENABLED, false)) {
        try {
            properties.put("ssl.truststore.password", getPassword(applicationProperties, TRUSTSTORE_PASSWORD_KEY));
        } catch (Exception e) {
            LOG.error("Exception while getpassword truststore.password ", e);
        }
    }

    // if no value is specified for max.poll.records, set to 1
    properties.put("max.poll.records", kafkaConf.getInt("max.poll.records", 1));

    setKafkaJAASProperties(applicationProperties, properties);

    LOG.info("<== KafkaNotification()");
}
 
Example 11
Source File: PageRankVertexProgram.java    From titan1withtp3.1 with Apache License 2.0 4 votes vote down vote up
@Override
public void loadState(final Graph graph, final Configuration configuration) {
    dampingFactor = configuration.getDouble(DAMPING_FACTOR, 0.85D);
    maxIterations = configuration.getInt(MAX_ITERATIONS, 10);
    vertexCount = configuration.getLong(VERTEX_COUNT, 1L);
}
 
Example 12
Source File: PistachiosServer.java    From Pistachio with Apache License 2.0 4 votes vote down vote up
public boolean init() {

        boolean initialized = false;

        logger.info("Initializing profile server...........");
        logger.info("do nothing setting {}", doNothing);
        try {
            // open profile store
            Configuration conf = ConfigurationManager.getConfiguration();
        ZKHelixAdmin admin = new ZKHelixAdmin(conf.getString(ZOOKEEPER_SERVER));
        IdealState idealState = admin.getResourceIdealState("PistachiosCluster", "PistachiosResource");
        long totalParition = (long)idealState.getNumPartitions();
            profileStore = new LocalStorageEngine(
                    conf.getString(PROFILE_BASE_DIR),
                    (int)totalParition, 8,
                    conf.getInt("StorageEngine.KC.RecordsPerPartition"),
                    conf.getLong("StorageEngine.KC.MemoryPerPartition"));
            ProcessorRegistry.getInstance().init();
            logger.info("creating helix partition sepctator {} {} {}", conf.getString(ZOOKEEPER_SERVER, "EMPTY"),
                    "PistachiosCluster", conf.getString(PROFILE_HELIX_INSTANCE_ID, "EMPTY"));
            helixPartitionSpectator = HelixPartitionSpectator.getInstance(
                    conf.getString(ZOOKEEPER_SERVER), // zkAddr
                    "PistachiosCluster",
                    NativeUtils.getHostname() //InetAddress.getLocalHost().getHostName() //conf.getString(PROFILE_HELIX_INSTANCE_ID) // instanceName
                    );
            // Partition Manager for line spending
            manager = new HelixPartitionManager<>(
                    conf.getString(ZOOKEEPER_SERVER), // zkAddr
                    "PistachiosCluster",
                    NativeUtils.getHostname() //InetAddress.getLocalHost().getHostName() //conf.getString(PROFILE_HELIX_INSTANCE_ID) // instanceName
                    );
            //manager.start("BootstrapOnlineOffline", new BootstrapOnlineOfflineStateModelFactory(new StorePartitionHandlerFactory()));
            manager.start("MasterSlave", new BootstrapOnlineOfflineStateModelFactory(new StorePartitionHandlerFactory()));
            //            }

            initialized = true;
        } catch (Exception e) {
            logger.error("Failed to initialize ProfileServerModule", e);
        }
        logger.info("Finished initializing profile server...........");

        return initialized;
    }