Java Code Examples for org.apache.commons.configuration.BaseConfiguration

The following examples show how to use org.apache.commons.configuration.BaseConfiguration. These examples are extracted from open source projects. 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 Project: hugegraph   Source File: MultiGraphsTest.java    License: Apache License 2.0 6 votes vote down vote up
public static HugeGraph openGraphWithBackend(String graph, String backend,
                                             String serializer,
                                             String... configs) {
    PropertiesConfiguration conf = Utils.getConf();
    Configuration config = new BaseConfiguration();
    for (Iterator<String> keys = conf.getKeys(); keys.hasNext();) {
        String key = keys.next();
        config.setProperty(key, conf.getProperty(key));
    }
    ((BaseConfiguration) config).setDelimiterParsingDisabled(true);
    config.setProperty(CoreOptions.STORE.name(), graph);
    config.setProperty(CoreOptions.BACKEND.name(), backend);
    config.setProperty(CoreOptions.SERIALIZER.name(), serializer);
    for (int i = 0; i < configs.length;) {
        config.setProperty(configs[i++], configs[i++]);
    }
    return ((HugeGraph) GraphFactory.open(config));
}
 
Example 2
@Test
public void testSegmentAlreadyThereAndExtraneousFilesDeleted()
    throws Exception {
  PinotFSFactory.init(new BaseConfiguration());
  File tableDir = new File(TEMP_DIR, RAW_TABLE_NAME);
  String segmentName = new LLCSegmentName(RAW_TABLE_NAME, 0, 0, CURRENT_TIME_MS).getSegmentName();
  String otherSegmentName = new LLCSegmentName(RAW_TABLE_NAME, 1, 0, CURRENT_TIME_MS).getSegmentName();
  String segmentFileName = SegmentCompletionUtils.generateSegmentFileName(segmentName);
  String extraSegmentFileName = SegmentCompletionUtils.generateSegmentFileName(segmentName);
  String otherSegmentFileName = SegmentCompletionUtils.generateSegmentFileName(otherSegmentName);
  File segmentFile = new File(tableDir, segmentFileName);
  File extraSegmentFile = new File(tableDir, extraSegmentFileName);
  File otherSegmentFile = new File(tableDir, otherSegmentFileName);
  FileUtils.write(segmentFile, "temporary file contents");
  FileUtils.write(extraSegmentFile, "temporary file contents");
  FileUtils.write(otherSegmentFile, "temporary file contents");

  FakePinotLLCRealtimeSegmentManager segmentManager = new FakePinotLLCRealtimeSegmentManager();
  String segmentLocation = SCHEME + tableDir + "/" + segmentFileName;
  CommittingSegmentDescriptor committingSegmentDescriptor = new CommittingSegmentDescriptor(segmentName,
      PARTITION_OFFSET.toString(), 0, segmentLocation);
  segmentManager.commitSegmentFile(REALTIME_TABLE_NAME, committingSegmentDescriptor);
  assertFalse(segmentFile.exists());
  assertFalse(extraSegmentFile.exists());
  assertTrue(otherSegmentFile.exists());
}
 
Example 3
@Override
protected ActiveVersionedGraph<?, Long> generateGraph() {
    File f = new File("/tmp/testgraph");
    if (f.exists()) {
        if (f.isDirectory()) {
            try {
                FileUtils.deleteDirectory(f);
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        } else {
            f.delete();
        }

    }

    Configuration c = new BaseConfiguration();
    c.addProperty("storage.directory","/tmp/testgraph");
    TitanGraph g = TitanFactory.open(c);

    return new ActiveVersionedGraph.ActiveVersionedTransactionalGraphBuilder<TitanGraph, Long>(g, new LongGraphIdentifierBehavior())
            .init(true).conf(null).build();
}
 
Example 4
Source Project: tinkergraph-gremlin   Source File: TinkerIoRegistryV2d0.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
    final TinkerGraph graph = TinkerGraph.open(conf);

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals("vertices")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
                    v.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        } else if (jsonParser.getCurrentName().equals("edges")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
                    e.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        }
    }

    return graph;
}
 
Example 5
Source Project: tinkergraph-gremlin   Source File: TinkerGraphTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistToGraphML() {
    final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGraphML.xml";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "graphml");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateModern(graph);
    graph.close();

    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertModernGraph(reloadedGraph, true, true);
    reloadedGraph.close();
}
 
Example 6
Source Project: tinkergraph-gremlin   Source File: TinkerGraphTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistToGraphSON() {
    final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGraphSON.json";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "graphson");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateModern(graph);
    graph.close();

    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertModernGraph(reloadedGraph, true, false);
    reloadedGraph.close();
}
 
Example 7
Source Project: tinkergraph-gremlin   Source File: TinkerGraphTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistToGryo() {
    final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGryo.kryo";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateModern(graph);
    graph.close();

    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertModernGraph(reloadedGraph, true, false);
    reloadedGraph.close();
}
 
Example 8
Source Project: tinkergraph-gremlin   Source File: TinkerGraphTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistToGryoAndHandleMultiProperties() {
    final String graphLocation = TestHelper.makeTestDataDirectory(TinkerGraphTest.class) + "shouldPersistToGryoMulti.kryo";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateTheCrew(graph);
    graph.close();

    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.toString());
    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertCrewGraph(reloadedGraph, false);
    reloadedGraph.close();
}
 
Example 9
Source Project: tinkergraph-gremlin   Source File: TinkerGraphTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPersistWithRelativePath() {
    final String graphLocation = TestHelper.convertToRelative(TinkerGraphTest.class,
            new File(TestHelper.makeTestDataDirectory(TinkerGraphTest.class)))  + "shouldPersistToGryoRelative.kryo";
    final File f = new File(graphLocation);
    if (f.exists() && f.isFile()) f.delete();

    final Configuration conf = new BaseConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION, graphLocation);
    final TinkerGraph graph = TinkerGraph.open(conf);
    TinkerFactory.generateModern(graph);
    graph.close();

    final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
    IoTest.assertModernGraph(reloadedGraph, true, false);
    reloadedGraph.close();
}
 
Example 10
Source Project: bitsy   Source File: BitsyGraph.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Configuration configuration() {
    if (this.origConfig != null) {
            return this.origConfig;
    } else {
        Configuration ans = new BaseConfiguration();
        ans.setProperty(DB_PATH_KEY, dbPath.toString());
        ans.setProperty(ALLOW_FULL_GRAPH_SCANS_KEY, allowFullGraphScans);
        ans.setProperty(DEFAULT_ISOLATION_LEVEL_KEY, defaultIsolationLevel.toString());
        ans.setProperty(TX_LOG_THRESHOLD_KEY, getTxLogThreshold());
        ans.setProperty(REORG_FACTOR_KEY, getReorgFactor());
        ans.setProperty(CREATE_DIR_IF_MISSING_KEY, createDirIfMissing);

        ans.setProperty(VERTEX_INDICES_KEY, String.join(",", getIndexedKeys(Vertex.class)));
        ans.setProperty(EDGE_INDICES_KEY, String.join(",", getIndexedKeys(Vertex.class)));

        return ans;
    }
}
 
Example 11
Source Project: titan1withtp3.1   Source File: ElasticSearchConfigTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testLocalNodeUsingExt() throws BackendException, InterruptedException {

    String baseDir = Joiner.on(File.separator).join("target", "es", "jvmlocal_ext");

    assertFalse(new File(baseDir + File.separator + "data").exists());

    CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.path.data", baseDir + File.separator + "data");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.path.work", baseDir + File.separator + "work");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.path.logs", baseDir + File.separator + "logs");
    ModifiableConfiguration config =
            new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
                    cc, BasicConfiguration.Restriction.NONE);
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();

    assertTrue(new File(baseDir + File.separator + "data").exists());
}
 
Example 12
Source Project: titan1withtp3.1   Source File: ElasticSearchConfigTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testLocalNodeUsingExtAndIndexDirectory() throws BackendException, InterruptedException {

    String baseDir = Joiner.on(File.separator).join("target", "es", "jvmlocal_ext2");

    assertFalse(new File(baseDir + File.separator + "data").exists());

    CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.data", "true");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.client", "false");
    cc.set("index." + INDEX_NAME + ".elasticsearch.ext.node.local", "true");
    ModifiableConfiguration config =
            new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
                    cc, BasicConfiguration.Restriction.NONE);
    config.set(INTERFACE, ElasticSearchSetup.NODE.toString(), INDEX_NAME);
    config.set(INDEX_DIRECTORY, baseDir, INDEX_NAME);
    Configuration indexConfig = config.restrictTo(INDEX_NAME);
    IndexProvider idx = new ElasticSearchIndex(indexConfig);
    simpleWriteAndQuery(idx);
    idx.close();

    assertTrue(new File(baseDir + File.separator + "data").exists());
}
 
Example 13
@Test
public void tryToConnectFail() throws IOException {
  OtrosApplication otrosApplication = new OtrosApplication();
  ConnectToSocketHubAppenderAction action = new ConnectToSocketHubAppenderAction(otrosApplication);
  DataConfiguration dc = new DataConfiguration(new BaseConfiguration());
  String hostAndPort = "abc:50";
  SocketFactory socketFactory = mock(SocketFactory.class);
  when(socketFactory.createSocket("abc", 50)).thenThrow(new UnknownHostException());

  try {
    action.tryToConnectToSocket(dc, hostAndPort, socketFactory);
    Assert.fail();
  } catch (UnknownHostException e) {
    //success
  }

  assertEquals(0, dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).size());
}
 
Example 14
Source Project: herd   Source File: ReloadablePropertySourceTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Asserts that when a property is requested from the configruation, and it fires an error event (ex. Database is not available), the previously stored
 * values are not cleared.
 */
@Test
public void testAssertGetPropertyErrorReturnPreviousValue() throws Exception
{
    // Get a reloadable property source that loads properties from the configuration every time a property is read.
    BaseConfiguration configuration = new BaseConfiguration()
    {
        @Override
        public Object getProperty(String key)
        {
            fireError(EVENT_READ_PROPERTY, key, null, new IllegalStateException("test exception"));
            return null;
        }
    };
    configuration.addProperty(TEST_KEY, TEST_VALUE_1);
    ReloadablePropertySource reloadablePropertySource = getNewReloadablePropertiesSource(0L, configuration);
    verifyPropertySourceValue(reloadablePropertySource, TEST_VALUE_1);
}
 
Example 15
Source Project: incubator-pinot   Source File: HadoopPinotFSTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCopy()
    throws IOException {
  URI baseURI = URI.create(TMP_DIR + "/HadoopPinotFSTest");
  HadoopPinotFS hadoopFS = new HadoopPinotFS();
  hadoopFS.init(new BaseConfiguration());
  hadoopFS.mkdir(new Path(baseURI.getPath(), "src").toUri());
  hadoopFS.mkdir(new Path(baseURI.getPath(), "src/dir").toUri());
  hadoopFS.touch(new Path(baseURI.getPath(), "src/dir/1").toUri());
  hadoopFS.touch(new Path(baseURI.getPath(), "src/dir/2").toUri());
  String[] srcFiles = hadoopFS.listFiles(new Path(baseURI.getPath(), "src").toUri(), true);
  Assert.assertEquals(srcFiles.length, 3);
  hadoopFS.copy(new Path(baseURI.getPath(), "src").toUri(), new Path(baseURI.getPath(), "dest").toUri());
  Assert.assertTrue(hadoopFS.exists(new Path(baseURI.getPath(), "dest").toUri()));
  Assert.assertTrue(hadoopFS.exists(new Path(baseURI.getPath(), "dest/dir").toUri()));
  Assert.assertTrue(hadoopFS.exists(new Path(baseURI.getPath(), "dest/dir/1").toUri()));
  Assert.assertTrue(hadoopFS.exists(new Path(baseURI.getPath(), "dest/dir/2").toUri()));
  String[] destFiles = hadoopFS.listFiles(new Path(baseURI.getPath(), "dest").toUri(), true);
  Assert.assertEquals(destFiles.length, 3);
  hadoopFS.delete(baseURI, true);
}
 
Example 16
Source Project: proarc   Source File: Z3950CatalogTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testReadFields() {
    final String catalogId = "catalogId";
    CatalogConfiguration c = new CatalogConfiguration(catalogId, "", new BaseConfiguration() {{
        addProperty(CatalogConfiguration.PROPERTY_FIELDS, "field1,field2 , field3  ");
        addProperty(CatalogConfiguration.FIELD_PREFIX + '.' + "field1" + '.' + Z3950Catalog.PROPERTY_FIELD_QUERY, "query1");
        addProperty(CatalogConfiguration.FIELD_PREFIX + '.' + "field2" + '.' + Z3950Catalog.PROPERTY_FIELD_QUERY, "query2");
    }});
    Map<String, Z3950Field> result = Z3950Catalog.readFields(c);
    assertNotNull(result);
    assertEquals(3, result.size());
    Z3950Field field1 = result.get("field1");
    assertNotNull("field1", field1);
    assertEquals("query1", field1.getQuery());
    Z3950Field field2 = result.get("field2");
    assertNotNull("field2", field2);
    assertEquals("query2", field2.getQuery());
    Z3950Field field3 = result.get("field3");
    assertNotNull("field3", field3);
    assertNull(field3.getQuery());
}
 
Example 17
@Test
    public void testAddInputFile() throws Exception {
        final String inputName = "input.txt";
        final File input = temp.newFile(inputName);
        final BaseConfiguration conf = new BaseConfiguration();
        conf.addProperty(ExternalProcess.PROP_EXEC, "test.sh");
        conf.addProperty(ExternalProcess.PROP_ARG, "-i ${input.file.name}");
        conf.addProperty(ExternalProcess.PROP_ARG, "-path ${input.file}[0]");
        conf.addProperty(ExternalProcess.PROP_ARG, "-o ${input.folder}");
        GenericExternalProcess gp = new GenericExternalProcess(conf).addInputFile(input);
        assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_NAME_EXT), input.getName());
        assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_PATH), input.getAbsolutePath());
        assertEquals(gp.getParameters().getMap().get(GenericExternalProcess.SRC_PARENT), input.getParentFile().getAbsolutePath());
        List<String> cmdLines = gp.buildCmdLine(conf);
//        System.out.println(cmdLines.toString());
    }
 
Example 18
Source Project: proarc   Source File: DesaServicesTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() {
    conf = new BaseConfiguration();
    conf.setProperty(DesaServices.PROPERTY_DESASERVICES, "ds1, dsNulls");

    String prefix = DesaServices.PREFIX_DESA + '.' + "ds1" + '.';
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_USER, "ds1user");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_PASSWD, "ds1passwd");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_PRODUCER, "ds1producer");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_OPERATOR, "ds1operator");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_EXPORTMODELS, "model:id1, model:id2");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_RESTAPI, "https://SERVER/dea-frontend/rest/sipsubmission");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_WEBSERVICE, "https://SERVER/dea-frontend/ws/SIPSubmissionService");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_NOMENCLATUREACRONYMS, "acr1, acr2");

    prefix = DesaServices.PREFIX_DESA + '.' + "dsNulls" + '.';
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_USER, null);
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_PASSWD, "");
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_EXPORTMODELS, null);
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_NOMENCLATUREACRONYMS, null);

    prefix = DesaServices.PREFIX_DESA + '.' + "dsNotActive" + '.';
    conf.setProperty(prefix + DesaConfiguration.PROPERTY_USER, "NA");
    desaServices = new DesaServices(conf);
}
 
Example 19
@Test
public void testFrom() {
    Configuration config = new BaseConfiguration();
    String[] excludes = {"ID1", "ID2", "ID3"};
    config.addProperty(Kramerius4ExportOptions.PROP_EXCLUDE_DATASTREAM_ID, excludes);

    config.addProperty(Kramerius4ExportOptions.PROP_RENAME_PREFIX + ".ID1", "NEWID1");
    config.addProperty(Kramerius4ExportOptions.PROP_RENAME_PREFIX + ".ID2", "NEWID2");

    String policy = "policy:public";
    config.addProperty(Kramerius4ExportOptions.PROP_POLICY, policy);

    Kramerius4ExportOptions result = Kramerius4ExportOptions.from(config);
    assertEquals(new HashSet<String>(Arrays.asList(excludes)), result.getExcludeDatastreams());
    assertEquals("NEWID1", result.getDsIdMap().get("ID1"));
    assertEquals("NEWID2", result.getDsIdMap().get("ID2"));
    assertEquals(policy, result.getPolicy());
}
 
Example 20
@Test
public void testBootstrapTable() {
  Map<String, Map<String, String>> currentAssignment = new TreeMap<>();
  for (String segmentName : SEGMENTS) {
    List<String> instancesAssigned =
        _segmentAssignment.assignSegment(segmentName, currentAssignment, _instancePartitionsMap);
    currentAssignment
        .put(segmentName, SegmentAssignmentUtils.getInstanceStateMap(instancesAssigned, SegmentStateModel.ONLINE));
  }

  // Bootstrap table should reassign all segments based on their alphabetical order
  Configuration rebalanceConfig = new BaseConfiguration();
  rebalanceConfig.setProperty(RebalanceConfigConstants.BOOTSTRAP, true);
  Map<String, Map<String, String>> newAssignment =
      _segmentAssignment.rebalanceTable(currentAssignment, _instancePartitionsMap, rebalanceConfig);
  assertEquals(newAssignment.size(), NUM_SEGMENTS);
  List<String> sortedSegments = new ArrayList<>(SEGMENTS);
  sortedSegments.sort(null);
  for (int i = 0; i < NUM_SEGMENTS; i++) {
    assertEquals(newAssignment.get(sortedSegments.get(i)), currentAssignment.get(SEGMENTS.get(i)));
  }
}
 
Example 21
Source Project: otroslogviewer   Source File: ShowConfigTest.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws UnsupportedLookAndFeelException {
  final SubstanceBusinessBlackSteelLookAndFeel newLookAndFeel = new SubstanceBusinessBlackSteelLookAndFeel();
  UIManager.setLookAndFeel(newLookAndFeel);
  DataConfiguration configuration = new DataConfiguration(new BaseConfiguration());
  ConfigurationProvider configurationProvider = new ConfigurationProviderImpl(configuration, new File(System.getProperty("java.io.tmpdir")));
  configuration.setProperty("view1.text", "ASD ASD");
  configuration.setProperty("view2.text", "sdf\nd\ndf\ns");
  JFrame f = new JFrame("CV");
  f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  f.getContentPane().setLayout(new BorderLayout());
  ConfigView[] configViews = {
      new View1(), // 
      new View2(), //
      new ViewTable(),// 
      new DateFormatView(),// 
      new ValidationView(),
      new ValidationView2()//
  };
  f.getContentPane().add(new ConfigComponent(configurationProvider, configViews));
  f.pack();
  f.setVisible(true);
}
 
Example 22
@Test
public void testCommitSegmentFile()
    throws Exception {
  PinotFSFactory.init(new BaseConfiguration());
  File tableDir = new File(TEMP_DIR, RAW_TABLE_NAME);
  String segmentName = new LLCSegmentName(RAW_TABLE_NAME, 0, 0, CURRENT_TIME_MS).getSegmentName();
  String segmentFileName = SegmentCompletionUtils.generateSegmentFileName(segmentName);
  File segmentFile = new File(tableDir, segmentFileName);
  FileUtils.write(segmentFile, "temporary file contents");

  FakePinotLLCRealtimeSegmentManager segmentManager = new FakePinotLLCRealtimeSegmentManager();
  String segmentLocation = SCHEME + tableDir + "/" + segmentFileName;
  CommittingSegmentDescriptor committingSegmentDescriptor = new CommittingSegmentDescriptor(segmentName,
      PARTITION_OFFSET.toString(), 0, segmentLocation);
  segmentManager.commitSegmentFile(REALTIME_TABLE_NAME, committingSegmentDescriptor);
  assertFalse(segmentFile.exists());
}
 
Example 23
Source Project: otroslogviewer   Source File: LogPatternsPage.java    License: Apache License 2.0 6 votes vote down vote up
private void importFromIde() {
  final BaseConfiguration configuration = new BaseConfiguration();
  final WizardSettings settings = this.getController().getSettings();
  configuration.setProperty(ConfKeys.JUMP_TO_CODE_HOST, settings.get(Config.IDE_HOST));
  configuration.setProperty(ConfKeys.JUMP_TO_CODE_PORT, settings.get(Config.IDE_PORT));
  loggerConfigTextPane.setEditable(false);
  loggerConfigTextPane.setText("Importing log patterns from IDE");
  new SwingWorker<Set<String>, Void>() {
    @Override
    protected Set<String> doInBackground() throws Exception {
      return new JumpToCodeServiceImpl(configuration).loggerPatterns();
    }

    @Override
    protected void done() {
      try {
        loggerConfigTextPane.setEditable(true);
        loggerConfigTextPane.setText(Joiner.on("\n").join(get()));
      } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
      }
    }
  }.execute();
}
 
Example 24
@BeforeMethod
public void setUp() throws ConfigurationException, IOException {
  p.put(PropertyPatternMessageColorizer.PROP_NAME, "Test");
  p.put(PropertyPatternMessageColorizer.PROP_DESCRIPTION, "D");
  p.put(PropertyPatternMessageColorizer.PROP_PATTERN, "a(\\d+\\(a\\))a");
  p.put("foreground", "#FFFF00");
  p.put("background", "#00FFFF");
  p.put("font.bold", "false");
  p.put("font.italic", "true");
  p.put("foreground.1", "#FF0000");
  p.put("background.1", "#0000FF");
  p.put("font.bold.1", "true");
  p.put("font.italic.1", "false");

  ByteArrayOutputStream bout = new ByteArrayOutputStream();
  p.store(bout, "");
  ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());

  colorizer = new PropertyPatternMessageColorizer(new ThemeConfig(new BaseConfiguration()));
  colorizer.init(bin);
}
 
Example 25
Source Project: incubator-pinot   Source File: PerfBenchmarkDriver.java    License: Apache License 2.0 5 votes vote down vote up
private void startBroker()
    throws Exception {
  if (!_conf.shouldStartBroker()) {
    LOGGER.info("Skipping start broker step. Assumes broker is already started.");
    return;
  }
  Configuration brokerConf = new BaseConfiguration();
  String brokerInstanceName = "Broker_localhost_" + CommonConstants.Helix.DEFAULT_BROKER_QUERY_PORT;
  brokerConf.setProperty(CommonConstants.Helix.Instance.INSTANCE_ID_KEY, brokerInstanceName);
  brokerConf.setProperty(CommonConstants.Broker.CONFIG_OF_BROKER_TIMEOUT_MS, BROKER_TIMEOUT_MS);
  LOGGER.info("Starting broker instance: {}", brokerInstanceName);
  new HelixBrokerStarter(brokerConf, _clusterName, _zkAddress).start();
}
 
Example 26
Source Project: incubator-pinot   Source File: PinotConfigUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static Configuration generateBrokerConf(int brokerPort) {
  if (brokerPort == 0) {
    brokerPort = getAvailablePort();
  }
  Configuration brokerConf = new BaseConfiguration();
  brokerConf.addProperty(CommonConstants.Helix.KEY_OF_BROKER_QUERY_PORT, brokerPort);
  return brokerConf;
}
 
Example 27
Source Project: tinkergraph-gremlin   Source File: TinkerGraph.java    License: Apache License 2.0 5 votes vote down vote up
public static final Configuration EMPTY_CONFIGURATION() {
    return new BaseConfiguration() {{
        this.setProperty(Graph.GRAPH, TinkerGraph.class.getName());
        this.setProperty(GREMLIN_TINKERGRAPH_OVERFLOW_HEAP_PERCENTAGE_THRESHOLD, 80);
        this.setProperty(GREMLIN_TINKERGRAPH_ONDISK_OVERFLOW_ENABLED, true);
    }};
}
 
Example 28
@Test
public void testLocalTempDirNotConfigured()
    throws Exception {
  FileUtils.deleteQuietly(DATA_DIR);
  PinotFSFactory.init(new BaseConfiguration());

  ControllerConf controllerConf = new ControllerConf();
  controllerConf.setControllerHost(HOST);
  controllerConf.setControllerPort(PORT);
  controllerConf.setDataDir(DATA_DIR.getPath());
  ControllerFilePathProvider.init(controllerConf);
  ControllerFilePathProvider provider = ControllerFilePathProvider.getInstance();

  URI dataDirURI = provider.getDataDirURI();
  assertEquals(dataDirURI, new URI("file:" + DATA_DIR.getAbsolutePath()));
  assertTrue(new File(dataDirURI).isDirectory());

  File fileUploadTempDir = provider.getFileUploadTempDir();
  assertEquals(fileUploadTempDir, new File(DATA_DIR, "localhost_12345/fileUploadTemp"));
  checkDirExistAndEmpty(fileUploadTempDir);

  File untarredFileTempDir = provider.getUntarredFileTempDir();
  assertEquals(untarredFileTempDir, new File(DATA_DIR, "localhost_12345/untarredFileTemp"));
  checkDirExistAndEmpty(untarredFileTempDir);

  File fileDownloadTempDir = provider.getFileDownloadTempDir();
  assertEquals(fileDownloadTempDir, new File(DATA_DIR, "localhost_12345/fileDownloadTemp"));
  checkDirExistAndEmpty(fileDownloadTempDir);

  assertEquals(provider.getVip(), "http://localhost:12345");

  FileUtils.forceDelete(DATA_DIR);
}
 
Example 29
@Test
public void testAllCustomServerConf()
    throws Exception {
  Configuration serverConf = new BaseConfiguration();
  serverConf.addProperty(CONFIG_OF_INSTANCE_ID, CUSTOM_INSTANCE_ID);
  serverConf.addProperty(KEY_OF_SERVER_NETTY_HOST, CUSTOM_HOST);
  serverConf.addProperty(KEY_OF_SERVER_NETTY_PORT, CUSTOM_PORT);
  verifyInstanceConfig(serverConf, CUSTOM_INSTANCE_ID, CUSTOM_HOST, CUSTOM_PORT);
}
 
Example 30
Source Project: tinkergraph-gremlin   Source File: TinkerIoRegistryV3d0.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public TinkerGraph read(final Kryo kryo, final Input input, final Class<TinkerGraph> tinkerGraphClass) {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
    final TinkerGraph graph = TinkerGraph.open(conf);
    final int len = input.readInt();
    final byte[] bytes = input.readBytes(len);
    try (final ByteArrayInputStream stream = new ByteArrayInputStream(bytes)) {
        GryoReader.build().mapper(() -> kryo).create().readGraph(stream, graph);
    } catch (Exception io) {
        throw new RuntimeException(io);
    }

    return graph;
}