Example usage for org.apache.commons.configuration Configuration setProperty

List of usage examples for org.apache.commons.configuration Configuration setProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration setProperty.

Prototype

void setProperty(String key, Object value);

Source Link

Document

Set a property, this will replace any previously set values.

Usage

From source file:graphene.dao.titan.BatchGraphTest.java

public static void main(String[] args) {
    Configuration conf = new BaseConfiguration();
    conf.setProperty("storage.backend", "cassandrathrift");
    conf.setProperty("storage.hostname", "127.0.0.1");
    //conf.setProperty("storage.port", 9160);
    TitanGraph g = TitanFactory.open(conf);
    BatchGraph<TitanGraph> bgraph = new BatchGraph(g, VertexIDType.STRING, 1000);
    // for (String[] quad : quads) {
    // Vertex[] vertices = new Vertex[2];
    // for (int i=0;i<2;i++) {
    // vertices[i] = bgraph.getVertex(quad[i]);
    // if (vertices[i]==null) vertices[i]=bgraph.addVertex(quad[i]);
    // }//w w w.jav  a2  s  .  c o m
    // Edge edge = bgraph.addEdge(null,vertices[0],vertices[1],quad[2]);
    // edge.setProperty("annotation",quad[3]);
    // }

    for (int k = 0; k < MAXNODES; k++) {
        Vertex[] vertices = new Vertex[2];

        for (int i = 0; i < 2; i++) {
            String id = "Vertex-" + rand.nextInt(MAXNODES);
            vertices[i] = bgraph.getVertex(id);
            if (vertices[i] == null) {
                vertices[i] = bgraph.addVertex(id);
                vertices[i].setProperty("label", id);
            }
        }
        String edgeId = "Edge-" + vertices[0].getId() + "--" + vertices[1].getId();
        Edge e = bgraph.getEdge(edgeId);
        if (e == null) {
            e = bgraph.addEdge(null, vertices[0], vertices[1], edgeId);
            DateTime dt = new DateTime();
            e.setProperty("edgeData", dt.getMillis());
        }
    }
    bgraph.commit();
    Iterator<Vertex> iter = bgraph.getVertices().iterator();
    logger.debug("Start iterating over vertices");
    while (iter.hasNext()) {
        Vertex v = iter.next();
        Iterator<Edge> eIter = v.getEdges(Direction.BOTH).iterator();
        while (eIter.hasNext()) {
            Edge currentEdge = eIter.next();
            String data = currentEdge.getProperty("edgeData");
            logger.debug("Observing edge " + currentEdge.getLabel());
            logger.debug("has edge with data: " + data + " from "
                    + currentEdge.getVertex(Direction.IN).getProperty("label") + " to "
                    + currentEdge.getVertex(Direction.OUT).getProperty("label"));
        }
    }
    logger.debug("Done iterating over vertices");
}

From source file:com.linkedin.pinot.perf.BitmapIndexCreationBenchmark.java

public static void main(String[] args) throws Exception {

    System.out.println("Starting generation");
    Configuration tableDataManagerConfig = new PropertiesConfiguration();
    List<String> indexColumns = Lists.newArrayList("contract_id", "seat_id");
    tableDataManagerConfig.setProperty(IndexLoadingConfigMetadata.KEY_OF_LOADING_INVERTED_INDEX, indexColumns);
    IndexLoadingConfigMetadata indexLoadingConfigMetadata = new IndexLoadingConfigMetadata(
            tableDataManagerConfig);//  w ww .j a v a2  s .  co  m
    ReadMode mode = ReadMode.heap;
    File indexDir = new File(
            "/home/kgopalak/pinot_perf/index_dir/capReportingEvents_OFFLINE/capReportingEvents_capReportingEvents_daily_2");
    long start = System.currentTimeMillis();
    Loaders.IndexSegment.load(indexDir, mode, indexLoadingConfigMetadata);
    long end = System.currentTimeMillis();
    System.out.println("Took " + (end - start) + " to generate bitmap index");
}

From source file:com.linkedin.pinot.perf.FilterOperatorBenchmark.java

public static void main(String[] args) throws Exception {
    String rootDir = args[0];// www  .ja va  2  s  .c o  m
    File[] segmentDirs = new File(rootDir).listFiles();
    String query = args[1];
    AtomicInteger totalDocsMatched = new AtomicInteger(0);
    Pql2Compiler pql2Compiler = new Pql2Compiler();
    BrokerRequest brokerRequest = pql2Compiler.compileToBrokerRequest(query);
    List<Callable<Void>> segmentProcessors = new ArrayList<>();
    long[] timesSpent = new long[segmentDirs.length];
    for (int i = 0; i < segmentDirs.length; i++) {
        File indexSegmentDir = segmentDirs[i];
        System.out.println("Loading " + indexSegmentDir.getName());
        Configuration tableDataManagerConfig = new PropertiesConfiguration();
        List<String> invertedColumns = new ArrayList<>();
        FilenameFilter filter = new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".bitmap.inv");
            }
        };
        String[] indexFiles = indexSegmentDir.list(filter);
        for (String indexFileName : indexFiles) {
            invertedColumns.add(indexFileName.replace(".bitmap.inv", ""));
        }
        tableDataManagerConfig.setProperty(IndexLoadingConfigMetadata.KEY_OF_LOADING_INVERTED_INDEX,
                invertedColumns);
        IndexLoadingConfigMetadata indexLoadingConfigMetadata = new IndexLoadingConfigMetadata(
                tableDataManagerConfig);
        IndexSegmentImpl indexSegmentImpl = (IndexSegmentImpl) Loaders.IndexSegment.load(indexSegmentDir,
                ReadMode.heap, indexLoadingConfigMetadata);
        segmentProcessors
                .add(new SegmentProcessor(i, indexSegmentImpl, brokerRequest, totalDocsMatched, timesSpent));
    }
    ExecutorService executorService = Executors.newCachedThreadPool();
    for (int run = 0; run < 5; run++) {
        System.out.println("START RUN:" + run);
        totalDocsMatched.set(0);
        long start = System.currentTimeMillis();
        List<Future<Void>> futures = executorService.invokeAll(segmentProcessors);
        for (int i = 0; i < futures.size(); i++) {
            futures.get(i).get();
        }
        long end = System.currentTimeMillis();
        System.out.println("Total docs matched:" + totalDocsMatched + " took:" + (end - start));
        System.out.println("Times spent:" + Arrays.toString(timesSpent));
        System.out.println("END RUN:" + run);
    }
    System.exit(0);
}

From source file:com.insilico.titan.Loader.java

public static Configuration initConfig() {
    Configuration conf = new BaseConfiguration();
    conf.setProperty("storage.backend", "hbase");
    conf.setProperty("storage.tablename", "spidral");

    conf.setProperty("storage.index.search.backend", "elasticsearch");
    conf.setProperty("storage.index.search.directory", "/app/elasticsearch");
    conf.setProperty("storage.index.search.client-only", false);
    conf.setProperty("storage.index.search.local-mode", true);

    return conf;//from w w w .j a v  a  2 s  .co m
}

From source file:co.turnus.trace.scheduler.devs.util.SimpleTest.java

private static Configuration parseArgs(String[] args) {
    Configuration config = new BaseConfiguration();
    config.setProperty(SENS_STATEVAR, false);
    config.setProperty(SENS_TOKENS, true);
    config.setProperty(SIMULATION_ID, "SimpleTest");

    if (args.length > 2) {
        config.setProperty(EXPORT_GANTT, true);
        config.setProperty(VCD_FILE, args[2]);
    } else {/*from   w  ww  .j  av  a  2s.  c  o  m*/
        config.setProperty(EXPORT_GANTT, false);
    }

    return config;
}

From source file:com.netflix.loadbalancer.ServerListLoabBalancerTest.java

@BeforeClass
public static void init() {
    Configuration config = ConfigurationManager.getConfigInstance();
    config.setProperty("ServerListLoabBalancerTest.ribbon.NFLoadBalancerClassName",
            com.netflix.loadbalancer.DynamicServerListLoadBalancer.class.getName());
    config.setProperty("ServerListLoabBalancerTest.ribbon.NIWSServerListClassName",
            FixedServerList.class.getName());
    lb = (DynamicServerListLoadBalancer<Server>) ClientFactory
            .getNamedLoadBalancer("ServerListLoabBalancerTest");
}

From source file:com.springrts.springls.ServerConfiguration.java

private static Configuration createDefaults() {

    Configuration configuration = new BaseConfiguration();

    configuration.setProperty(PORT, 8200);
    configuration.setProperty(NAT_PORT, 8201);
    configuration.setProperty(LAN_MODE, false);
    configuration.setProperty(STATISTICS_STORE, false);
    configuration.setProperty(LAN_ADMIN_USERNAME, "admin");
    configuration.setProperty(LAN_ADMIN_PASSWORD, "admin");
    configuration.setProperty(CHANNELS_LOG_REGEX, "^%%%%%%%$"); // match no channel
    configuration.setProperty(ENGINE_VERSION, "*"); // all versions
    configuration.setProperty(LOBBY_PROTOCOL_VERSION, "0.35");
    configuration.setProperty(USE_DATABASE, false);

    return configuration;
}

From source file:co.turnus.analysis.profiler.orcc.code.OrccStaticProfilerOptions.java

public static Configuration getConfiguration(ILaunchConfiguration configuration, String mode) {
    Configuration conf = new BaseConfiguration();

    try {// ww w . ja v a  2s.  c  o m
        conf.setProperty(VERBOSE, mode.equals("debug"));

        String stmp = configuration.getAttribute(ORCC_PROJECT, "");
        conf.setProperty(ORCC_PROJECT, stmp);

        stmp = configuration.getAttribute(ORCC_XDF, "");
        conf.setProperty(ORCC_XDF, stmp);

        stmp = configuration.getAttribute(VERSIONER, GitVersioner.NAME);
        conf.setProperty(VERSIONER, stmp);

        // set the output path
        stmp = configuration.getAttribute(OUTPUT_PATH_CUSTOM_USE, false)
                ? configuration.getAttribute(OUTPUT_PATH_CUSTOM_VALUE, "")
                : "";
        setOutputPath(conf, stmp);
    } catch (Exception e) {
        throw new TurnusRuntimeException("Error parsing the launch configuration options", e);
    }

    return conf;
}

From source file:fresto.Global.java

public static TitanGraph openGraph() {
    Configuration conf = new BaseConfiguration();
    //conf.setProperty("storage.backend", "cassandra"); 
    conf.setProperty("storage.backend", TITAN_STORAGE_BACKEND);
    conf.setProperty("storage.hostname", TITAN_STORAGE_HOSTNAME);
    // Default//from   w w w  . ja  v a  2 s  .  com
    //conf.setProperty("storage.connection-pool-size", 32); 
    g = TitanFactory.open(conf);
    return g;
}

From source file:co.turnus.analysis.pipelining.SimplePipeliningCliLauncher.java

private static Configuration parseCommandLine(CommandLine cmd) throws ParseException {
    Configuration config = new BaseConfiguration();

    StringBuffer s = new StringBuffer();

    config.setProperty(VERBOSE, cmd.hasOption("v"));

    if (!cmd.hasOption("t")) {
        s.append("Trace project directory not specified. ");
    } else {/*from  w w w. j a va 2  s  .c  om*/
        String fileName = cmd.getOptionValue("t", "");
        File file = new File(fileName);
        if (file == null || !file.exists()) {
            s.append("Trace project does not exists. ");
        } else {
            config.setProperty(TRACE_PROJECT, fileName);
        }
    }

    if (!cmd.hasOption("o")) {
        s.append("Output directory not specified. ");
    } else {
        String fileName = cmd.getOptionValue("o", "");
        File file = new File(fileName);
        if (file == null || !file.exists()) {
            s.append("Output directory does not exists. ");
        } else {
            config.setProperty(OUTPUT_PATH, fileName);
        }
    }

    if (cmd.hasOption("xls")) {
        String fileName = cmd.getOptionValue("xls", "");
        if (fileName == null || fileName.isEmpty()) {
            s.append("XLS file name is not correct. ");
        } else {
            config.setProperty(XLS, fileName);
        }

    }

    String error = s.toString();
    if (!error.isEmpty()) {
        throw new ParseException(error);
    }

    return config;
}