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

The following examples show how to use org.apache.commons.configuration.Configuration#addProperty() . 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: chassis   File: ConfigurationBuilder.java    License: Apache License 2.0 6 votes vote down vote up
private void addServerInstanceProperties(Configuration configuration) {
    String instanceId = LOCAL_INSTANCE_ID;
    String region = UNKNOWN;
    String availabilityZone = UNKNOWN;
    String privateIp = "127.0.0.1";
    String publicIp = null;
    String instanceName = Joiner.on("-").join(appEnvironment, appName, appVersion);

    if (serverInstanceContext != null) {
        instanceId = serverInstanceContext.getInstanceId();
        region = serverInstanceContext.getRegion();
        availabilityZone = serverInstanceContext.getAvailabilityZone();
        privateIp = serverInstanceContext.getPrivateIp();
        publicIp = serverInstanceContext.getPublicIp();
    }

    configuration.addProperty(BootstrapConfigKeys.AWS_INSTANCE_ID.getPropertyName(), instanceId);
    configuration.addProperty(BootstrapConfigKeys.AWS_INSTANCE_REGION.getPropertyName(), region);
    configuration.addProperty(BootstrapConfigKeys.AWS_INSTANCE_AVAILABILITY_ZONE.getPropertyName(), availabilityZone);
    configuration.addProperty(BootstrapConfigKeys.AWS_INSTANCE_PRIVATE_IP.getPropertyName(), privateIp);
    if (publicIp != null) {
        configuration.addProperty(BootstrapConfigKeys.AWS_INSTANCE_PUBLIC_IP.getPropertyName(), publicIp);
    }
    configuration.addProperty(BootstrapConfigKeys.AWS_INSTANCE_NAME.getPropertyName(), instanceName);
}
 
Example 2
public static Configuration getConfiguration() throws AtlasException {
    Configuration configProperties = ApplicationProperties.get();

    Configuration titanConfig = ApplicationProperties.getSubsetConfiguration(configProperties, GRAPH_PREFIX);

    //add serializers for non-standard property value types that Atlas uses

    titanConfig.addProperty("attributes.custom.attribute1.attribute-class", TypeCategory.class.getName());
    titanConfig.addProperty("attributes.custom.attribute1.serializer-class",
            TypeCategorySerializer.class.getName());

    //not ideal, but avoids making large changes to Atlas
    titanConfig.addProperty("attributes.custom.attribute2.attribute-class", ArrayList.class.getName());
    titanConfig.addProperty("attributes.custom.attribute2.serializer-class", StringListSerializer.class.getName());

    titanConfig.addProperty("attributes.custom.attribute3.attribute-class", BigInteger.class.getName());
    titanConfig.addProperty("attributes.custom.attribute3.serializer-class", BigIntegerSerializer.class.getName());

    titanConfig.addProperty("attributes.custom.attribute4.attribute-class", BigDecimal.class.getName());
    titanConfig.addProperty("attributes.custom.attribute4.serializer-class", BigDecimalSerializer.class.getName());

    return titanConfig;
}
 
Example 3
private void startServer()
    throws Exception {
  if (!_conf.shouldStartServer()) {
    LOGGER.info("Skipping start server step. Assumes server is already started.");
    return;
  }
  Configuration serverConfiguration = new PropertiesConfiguration();
  serverConfiguration.addProperty(CommonConstants.Server.CONFIG_OF_INSTANCE_DATA_DIR, _serverInstanceDataDir);
  serverConfiguration
      .addProperty(CommonConstants.Server.CONFIG_OF_INSTANCE_SEGMENT_TAR_DIR, _serverInstanceSegmentTarDir);
  serverConfiguration.addProperty(CommonConstants.Helix.KEY_OF_SERVER_NETTY_HOST, "localhost");
  if (_segmentFormatVersion != null) {
    serverConfiguration.setProperty(CommonConstants.Server.CONFIG_OF_SEGMENT_FORMAT_VERSION, _segmentFormatVersion);
  }
  serverConfiguration.setProperty(CommonConstants.Server.CONFIG_OF_INSTANCE_ID, _serverInstanceName);
  LOGGER.info("Starting server instance: {}", _serverInstanceName);
  HelixServerStarter helixServerStarter = new HelixServerStarter(_clusterName, _zkAddress, serverConfiguration);
  helixServerStarter.start();
}
 
Example 4
Source Project: juddi   File: ClientConfig.java    License: Apache License 2.0 6 votes vote down vote up
private void addSubscriptionCallback(Configuration cc) {
        if (this.config.containsKey(SubscriptionCallbackListener.PROPERTY_AUTOREG_BT)) {
                cc.addProperty(SubscriptionCallbackListener.PROPERTY_AUTOREG_BT, this.config.getProperty(SubscriptionCallbackListener.PROPERTY_AUTOREG_BT));
        }
        if (this.config.containsKey(SubscriptionCallbackListener.PROPERTY_AUTOREG_SERVICE_KEY)) {
                cc.addProperty(SubscriptionCallbackListener.PROPERTY_AUTOREG_SERVICE_KEY, this.config.getProperty(SubscriptionCallbackListener.PROPERTY_AUTOREG_SERVICE_KEY));
        }
        if (this.config.containsKey(SubscriptionCallbackListener.PROPERTY_KEYDOMAIN)) {
                cc.addProperty(SubscriptionCallbackListener.PROPERTY_KEYDOMAIN, this.config.getProperty(SubscriptionCallbackListener.PROPERTY_KEYDOMAIN));
        }
        if (this.config.containsKey(SubscriptionCallbackListener.PROPERTY_LISTENURL)) {
                cc.addProperty(SubscriptionCallbackListener.PROPERTY_LISTENURL, this.config.getProperty(SubscriptionCallbackListener.PROPERTY_LISTENURL));
        }
        if (this.config.containsKey(SubscriptionCallbackListener.PROPERTY_NODE)) {
                cc.addProperty(SubscriptionCallbackListener.PROPERTY_NODE, this.config.getProperty(SubscriptionCallbackListener.PROPERTY_NODE));
        }
        if (this.config.containsKey(SubscriptionCallbackListener.PROPERTY_SIGNATURE_BEHAVIOR)) {
                cc.addProperty(SubscriptionCallbackListener.PROPERTY_SIGNATURE_BEHAVIOR, this.config.getProperty(SubscriptionCallbackListener.PROPERTY_SIGNATURE_BEHAVIOR));
        }
}
 
Example 5
Source Project: atlas   File: AtlasJanusGraphDatabase.java    License: Apache License 2.0 5 votes vote down vote up
public static Configuration getConfiguration() throws AtlasException {
    startLocalSolr();

    Configuration configProperties = ApplicationProperties.get();

    if (isEmbeddedSolr()) { // AtlasJanusGraphIndexClient.performRequestHandlerAction() fails for embedded-solr; disable freetext until this issue is resolved
        configProperties.setProperty(ApplicationProperties.ENABLE_FREETEXT_SEARCH_CONF, false);
    }

    configProperties.setProperty(SOLR_ZOOKEEPER_URLS, configProperties.getStringArray(SOLR_ZOOKEEPER_URL));

    Configuration janusConfig = ApplicationProperties.getSubsetConfiguration(configProperties, GRAPH_PREFIX);

    //add serializers for non-standard property value types that Atlas uses
    janusConfig.addProperty("attributes.custom.attribute1.attribute-class", TypeCategory.class.getName());
    janusConfig.addProperty("attributes.custom.attribute1.serializer-class", TypeCategorySerializer.class.getName());

    //not ideal, but avoids making large changes to Atlas
    janusConfig.addProperty("attributes.custom.attribute2.attribute-class", ArrayList.class.getName());
    janusConfig.addProperty("attributes.custom.attribute2.serializer-class", SerializableSerializer.class.getName());

    janusConfig.addProperty("attributes.custom.attribute3.attribute-class", BigInteger.class.getName());
    janusConfig.addProperty("attributes.custom.attribute3.serializer-class", BigIntegerSerializer.class.getName());

    janusConfig.addProperty("attributes.custom.attribute4.attribute-class", BigDecimal.class.getName());
    janusConfig.addProperty("attributes.custom.attribute4.serializer-class", BigDecimalSerializer.class.getName());

    return janusConfig;
}
 
Example 6
@Test
public void testSetInstanceIdToHostname()
    throws Exception {
  Configuration serverConf = new BaseConfiguration();
  serverConf.addProperty(SET_INSTANCE_ID_TO_HOSTNAME_KEY, true);
  String expectedHost = NetUtil.getHostnameOrAddress();
  String expectedInstanceId = PREFIX_OF_SERVER_INSTANCE + expectedHost + "_" + DEFAULT_SERVER_NETTY_PORT;
  verifyInstanceConfig(serverConf, expectedInstanceId, expectedHost, DEFAULT_SERVER_NETTY_PORT);
}
 
Example 7
private static void addRecursive(Configuration target, Configuration source, String key) {
	Iterator<String> keys2 = source.getKeys(key);
	while(keys2.hasNext()) {
		String key2 = keys2.next();
		target.addProperty(key2, source.getProperty(key2));
		for(String tmpKey : source.getStringArray(key2)) {
			addRecursive(target, source, tmpKey);
		}
	}
}
 
Example 8
@Test(dependsOnMethods = "testDefaultSegmentFetcherFactory")
public void testCustomizedSegmentFetcherFactory()
    throws Exception {
  Configuration config = new BaseConfiguration();
  config.addProperty("foo", "bar");
  config.addProperty("protocols", Arrays.asList(HTTP_PROTOCOL, HTTPS_PROTOCOL, TEST_PROTOCOL, "foo"));
  config.addProperty("http.foo", "bar");
  config.addProperty(TEST_PROTOCOL + SegmentFetcherFactory.SEGMENT_FETCHER_CLASS_KEY_SUFFIX,
      TestSegmentFetcher.class.getName());
  SegmentFetcherFactory.init(config);

  assertEquals(SegmentFetcherFactory.getSegmentFetcher(HTTP_PROTOCOL).getClass(), HttpSegmentFetcher.class);
  assertEquals(SegmentFetcherFactory.getSegmentFetcher(HTTPS_PROTOCOL).getClass(), HttpsSegmentFetcher.class);
  assertEquals(SegmentFetcherFactory.getSegmentFetcher(FILE_PROTOCOL).getClass(), PinotFSSegmentFetcher.class);
  assertEquals(SegmentFetcherFactory.getSegmentFetcher("foo").getClass(), PinotFSSegmentFetcher.class);
  assertEquals(SegmentFetcherFactory.getSegmentFetcher(TEST_PROTOCOL).getClass(), TestSegmentFetcher.class);

  TestSegmentFetcher testFileFetcher = (TestSegmentFetcher) SegmentFetcherFactory.getSegmentFetcher(TEST_PROTOCOL);
  assertEquals(testFileFetcher._initCalled, 1);
  assertEquals(testFileFetcher._fetchFileToLocalCalled, 0);

  SegmentFetcherFactory.fetchSegmentToLocal(new URI(TEST_URI), new File("foo/bar"));
  assertEquals(testFileFetcher._initCalled, 1);
  assertEquals(testFileFetcher._fetchFileToLocalCalled, 1);

  SegmentFetcherFactory.fetchSegmentToLocal(TEST_URI, new File("foo/bar"));
  assertEquals(testFileFetcher._initCalled, 1);
  assertEquals(testFileFetcher._fetchFileToLocalCalled, 2);
}
 
Example 9
/**
 * Tests if all roles are fill
 */
@Test
public void missingRole() throws Exception {
    for (MetsExportTestElement testElement : testElements) {
        // copyFiles(testElement);
        String sourceDirPath = getTargetPath() + File.separator +
                testElement.getDirectory() + File.separator;
        File resultDir = tmp.newFolder("result" + testElement.getResultFolder());
        String path = sourceDirPath + testElement.getInitialDocument();
        DigitalObject dbObj = MetsUtils.readFoXML(path);
        Configuration config = new BaseConfiguration();
        config.addProperty(NdkExportOptions.PROP_NDK_AGENT_ARCHIVIST, "Archivist");
        config.addProperty(NdkExportOptions.PROP_NDK_AGENT_CREATOR, "");
        MetsContext context = new MetsContext();
        context.setPath(sourceDirPath);
        context.setFsParentMap(TestConst.parents);
        context.setOutputPath(resultDir.getAbsolutePath());
        context.setAllowNonCompleteStreams(true);
        context.setAllowMissingURNNBN(true);
        context.setConfig(NdkExportOptions.getOptions(config));
        MetsElement metsElement = MetsElement.getElement(dbObj, null, context, true);
        MetsElementVisitor visitor = new MetsElementVisitor();
        try {
            metsElement.accept(visitor);
            Assert.fail("The validation error expected.");
        } catch (MetsExportException ex) {
            String message = "Error - missing role. Please insert value in proarc.cfg into export.ndk.agent.creator and export.ndk.agent.archivist";
            assertEquals(message, ex.getMessage());
        }
    }
}
 
Example 10
@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 11
@Test
public void testGetOptions() {
    Configuration config = new BaseConfiguration();

    String creator = "KNAV";
    config.addProperty(NdkExportOptions.PROP_NDK_AGENT_CREATOR, creator);

    String archivist = "ProArc";
    config.addProperty(NdkExportOptions.PROP_NDK_AGENT_ARCHIVIST, archivist);

    NdkExportOptions result = NdkExportOptions.getOptions(config);

    assertEquals("creator", creator, result.getCreator());
    assertEquals("archivist", archivist, result.getArchivist());
}
 
Example 12
/**
     * http://db.apache.org/torque/torque-4.0/documentation/orm-reference/initialisation-configuration.html
     * http://commons.apache.org/proper/commons-dbcp/configuration.html
     *
     * @param config
     * @return
     */
    private Configuration buildConfiguration(ConnectionConfig config){
        Configuration configuration = new BaseConfiguration();


        String databaseName = config.getDatabaseName();
        if(databaseName==null){
            LOG.warn(JdbcConstants.EAGLE_DATABASE+" is null, trying default database name as: eagle");
            databaseName = "eagle";
        }

        LOG.info("Using default database: "+databaseName+" (adapter: "+config.getAdapter()+")");

        configuration.addProperty("torque.database.default",config.getDatabaseName());

        // This factory uses the SharedDataSource available in the commons-dbcp package
        configuration.addProperty(String.format("torque.dsfactory.%s.factory",databaseName), DEFAULT_DATA_SOURCE_FACTORY_CLASS);

        // mysql, oracle, ...
        configuration.addProperty(String.format("torque.database.%s.adapter",databaseName),config.getAdapter());

        // "org.gjt.mm.mysql.Driver"
        configuration.addProperty(String.format("torque.dsfactory.%s.connection.driver",databaseName),config.getDriverClassName());

        configuration.addProperty(String.format("torque.dsfactory.%s.connection.url",databaseName),config.getConnectionUrl());
        configuration.addProperty(String.format("torque.dsfactory.%s.connection.user",databaseName),config.getUserName());
        configuration.addProperty(String.format("torque.dsfactory.%s.connection.password",databaseName),config.getPassword());
        configuration.addProperty(String.format("torque.dsfactory.%s.pool.maxActive",databaseName),Integer.toString(config.getConnectionMaxActive()));
//        configuration.addProperty(String.format("torque.dsfactory.%s.pool.minIdle",databaseName),Integer.toString(config.getConnectionMinIdle()));
//        configuration.addProperty(String.format("torque.dsfactory.%s.pool.initialSize",databaseName),Integer.toString(config.getConnectionInitialSize()));

        return configuration;
    }
 
Example 13
Source Project: Eagle   File: TestTorque.java    License: Apache License 2.0 5 votes vote down vote up
public void setUp() throws TorqueException {
    Configuration configuration = new BaseConfiguration();
    configuration.addProperty("torque.database.default","eagle");
    configuration.addProperty("torque.database.eagle.adapter","mysql");
    configuration.addProperty("torque.dsfactory.eagle.factory","org.apache.torque.dsfactory.SharedPoolDataSourceFactory");

    configuration.addProperty("torque.dsfactory.eagle.connection.driver","org.gjt.mm.mysql.Driver");
    configuration.addProperty("torque.dsfactory.eagle.connection.url","jdbc:mysql://localhost:3306/eagle");
    configuration.addProperty("torque.dsfactory.eagle.connection.user","eagle");
    configuration.addProperty("torque.dsfactory.eagle.connection.password","eagle");

    Torque.init(configuration);
}
 
Example 14
public static HelixBrokerStarter getDefault()
    throws Exception {
  Configuration brokerConf = new BaseConfiguration();
  int port = 5001;
  brokerConf.addProperty(Helix.KEY_OF_BROKER_QUERY_PORT, port);
  brokerConf.addProperty(Broker.CONFIG_OF_BROKER_TIMEOUT_MS, 60 * 1000L);
  return new HelixBrokerStarter(brokerConf, "quickstart", "localhost:2122");
}
 
Example 15
Source Project: juddi   File: AuthenticatorTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testDecryptFromConfigXML_InMemory() 
{
               System.out.println("testDecryptFromConfigXML_InMemory");
	try {
                   Configuration config =AppConfig.getConfiguration();
                   
		Cryptor auth = new AES128Cryptor();
                       String encrypt = auth.encrypt("test");
                       Assert.assertNotNull(encrypt);
                       Assert.assertNotSame(encrypt, "test");
                       
                       //add to the config
                       config.addProperty("testDecryptFromConfigXML", encrypt);
                       config.addProperty("testDecryptFromConfigXML"+ Property.ENCRYPTED_ATTRIBUTE, "true");
                       
                       //retrieve it
                       String pwd = config.getString("testDecryptFromConfigXML");
                       Assert.assertNotNull(pwd);
                       //test for encryption
                       if (config.getBoolean("testDecryptFromConfigXML" + Property.ENCRYPTED_ATTRIBUTE, false))
                       {
                           String test=auth.decrypt(pwd);
                           Assert.assertEquals(test, "test");
                       }
                       else
                       {
                           Assert.fail("config reports that the setting is not encrypted");
                      }
               }
               catch (Exception e) {
		logger.error(e.getMessage(),e);
		Assert.fail("unexpected");
	}
}
 
Example 16
private static final Configuration generateBaseTitanConfiguration(GraphDatabaseType type, File dbPath,
    boolean batchLoading, BenchmarkConfiguration bench)
{
    if (!GraphDatabaseType.TITAN_FLAVORS.contains(type))
    {
        throw new IllegalArgumentException("must provide a Titan database type but got "
            + (type == null ? "null" : type.name()));
    }

    if (dbPath == null)
    {
        throw new IllegalArgumentException("the dbPath must not be null");
    }
    if (!dbPath.exists() || !dbPath.canWrite() || !dbPath.isDirectory())
    {
        throw new IllegalArgumentException("db path must exist as a directory and must be writeable");
    }

    final Configuration conf = new MapConfiguration(new HashMap<String, String>());
    final Configuration storage = conf.subset(GraphDatabaseConfiguration.STORAGE_NS.getName());
    final Configuration ids = conf.subset(GraphDatabaseConfiguration.IDS_NS.getName());
    final Configuration metrics = conf.subset(GraphDatabaseConfiguration.METRICS_NS.getName());

    conf.addProperty(GraphDatabaseConfiguration.ALLOW_SETTING_VERTEX_ID.getName(), "true");

    // storage NS config. FYI, storage.idauthority-wait-time is 300ms
    storage.addProperty(GraphDatabaseConfiguration.STORAGE_BACKEND.getName(), type.getBackend());
    storage.addProperty(GraphDatabaseConfiguration.STORAGE_DIRECTORY.getName(), dbPath.getAbsolutePath());
    storage.addProperty(GraphDatabaseConfiguration.STORAGE_BATCH.getName(), Boolean.toString(batchLoading));
    storage.addProperty(GraphDatabaseConfiguration.BUFFER_SIZE.getName(), bench.getTitanBufferSize());
    storage.addProperty(GraphDatabaseConfiguration.PAGE_SIZE.getName(), bench.getTitanPageSize());

    // ids NS config
    ids.addProperty(GraphDatabaseConfiguration.IDS_BLOCK_SIZE.getName(), bench.getTitanIdsBlocksize());

    // Titan metrics - https://github.com/thinkaurelius/titan/wiki/Titan-Performance-and-Monitoring
    metrics.addProperty(GraphDatabaseConfiguration.BASIC_METRICS.getName(), "true");
    metrics.addProperty("prefix", type.getShortname());
    if(bench.publishGraphiteMetrics()) {
        final Configuration graphite = metrics.subset(BenchmarkConfiguration.GRAPHITE);
        graphite.addProperty("hostname", bench.getGraphiteHostname());
        graphite.addProperty(BenchmarkConfiguration.CSV_INTERVAL, bench.getCsvReportingInterval());
    }
    if(bench.publishCsvMetrics()) {
        final Configuration csv = metrics.subset(GraphDatabaseConfiguration.METRICS_CSV_NS.getName());
        csv.addProperty(GraphDatabaseConfiguration.METRICS_CSV_DIR.getName(), bench.getCsvDir().getAbsolutePath());
        csv.addProperty(BenchmarkConfiguration.CSV_INTERVAL, bench.getCsvReportingInterval());
    }
    
    return conf;
}
 
Example 17
/**
 *
 * Saves a mets document and test it for different parameters (size, number
 * of files, ...)
 *
 * @throws Exception
 */
@Test
public void saveMetsTest() throws Exception {
    for (MetsExportTestElement testElement : testElements) {
        // copyFiles(testElement);
        String sourceDirPath = getTargetPath() + File.separator +
                testElement.getDirectory() + File.separator;
        File resultDir = tmp.newFolder("result" + testElement.getResultFolder());
        String path = sourceDirPath + testElement.getInitialDocument();
        DigitalObject dbObj = MetsUtils.readFoXML(path);
        Configuration config = new BaseConfiguration();
        config.addProperty(NdkExportOptions.PROP_NDK_AGENT_ARCHIVIST, "Archivist");
        config.addProperty(NdkExportOptions.PROP_NDK_AGENT_CREATOR, "Creator");
        MetsContext context = new MetsContext();
        context.setPath(sourceDirPath);
        context.setFsParentMap(TestConst.parents);
        context.setOutputPath(resultDir.getAbsolutePath());
        context.setAllowNonCompleteStreams(true);
        context.setAllowMissingURNNBN(true);
        context.setConfig(NdkExportOptions.getOptions(config));
        MetsElement metsElement = MetsElement.getElement(dbObj, null, context, true);
        MetsElementVisitor visitor = new MetsElementVisitor();
        metsElement.accept(visitor);
        String packageId = context.getGeneratedPSP().get(0);
        File infoFile = new File(resultDir.getAbsolutePath() + File.separator + packageId + File.separator +
                "info_" + packageId + ".xml");
        JAXBContext jaxbContext = JAXBContext.newInstance(Info.class);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        Info info = (Info) unmarshaller.unmarshal(infoFile);
        assertEquals(1 + testElement.getTotalItems(),
                info.getItemlist().getItemtotal().intValue());
        if (System.getProperty("os.name").toLowerCase().contains("win")) {
            // this is an aproximation as the precompute sizes ignore win EOLs
            assertTrue(info.getSize() != 0 && testElement.getSize() <= info.getSize());
        } else {
            assertEquals(testElement.getSize(), info.getSize());
        }
        File metsFile = new File(resultDir.getAbsolutePath() + File.separator + packageId + File.separator +
                "mets_" + packageId + ".xml");
        JAXBContext jaxbContextMets = JAXBContext.newInstance(Mets.class);
        Unmarshaller unmarshallerMets = jaxbContextMets.createUnmarshaller();
        Mets mets = (Mets) unmarshallerMets.unmarshal(metsFile);
        assertEquals(testElement.getNumberOfFiles(),
                mets.getFileSec().getFileGrp().size());
        assertEquals(testElement.getType(), mets.getTYPE());

        String expectedFileName = "txt_" + packageId + "_0001";
        String actualFileName = ((FileType)(mets.getStructMap().get(1).getDiv().getDiv().get(0).getFptr().get(0).getFILEID())).getID();
        assertEquals(expectedFileName, actualFileName);

        String expectedFileHref = "txt/" + expectedFileName + ".txt";
        String actualFileHref = mets.getFileSec().getFileGrp().get(0).getFile().get(0).getFLocat().get(0).getHref();
        assertEquals(expectedFileHref, actualFileHref);
    }
}
 
Example 18
/**
 * Tests if the exception is thrown for invalid mets
 *
 */
@Test
public void testAmdSec() throws Exception {
    String sourceDirPath = getTargetPath() + File.separator +
            "monograph" + File.separator;
    File resultDir = tmp.newFolder("result" + "monograph");
    String path = sourceDirPath + "1ccbf6c5-b22c-4d89-b42e-8cd14101a737.xml";
    DigitalObject dbObj = MetsUtils.readFoXML(path);
    Configuration config = new BaseConfiguration();
    config.addProperty(NdkExportOptions.PROP_NDK_AGENT_CREATOR, "Creator");
    config.addProperty(NdkExportOptions.PROP_NDK_AGENT_ARCHIVIST, "Archivist");
    MetsContext context = new MetsContext();
    context.setPath(sourceDirPath);
    context.setFsParentMap(TestConst.parents);
    context.setOutputPath(resultDir.getAbsolutePath());
    context.setAllowNonCompleteStreams(true);
    context.setAllowMissingURNNBN(true);
    context.setConfig(NdkExportOptions.getOptions(config));
    MetsElement metsElement = MetsElement.getElement(dbObj, null, context, true);
    MetsElementVisitor visitor = new MetsElementVisitor();
    metsElement.accept(visitor);
    File amdSecFile = new File(resultDir.getAbsolutePath()+File.separator+"44589055-9fad-4a9f-b6a8-75be399f332d"+File.separator+"amdsec"+File.separator+"amd_mets_44589055-9fad-4a9f-b6a8-75be399f332d_0001.xml");
    JAXBContext jaxbContextMets = JAXBContext.newInstance(Mets.class);
    Unmarshaller unmarshallerMets = jaxbContextMets.createUnmarshaller();
    Mets mets = (Mets) unmarshallerMets.unmarshal(amdSecFile);
    assertEquals("PAGE_0001", mets.getAmdSec().get(0).getID());
    List<MdSecType> techMDList = mets.getAmdSec().get(0).getTechMD();
    assertEquals(4, techMDList.size());
    for (MdSecType techMD : techMDList) {
    if ("MIX_002".equals(techMD.getID())) {
        XmlData mixData = techMD.getMdWrap().getXmlData();
        List<Element> mixElements = new ArrayList<Element>();
        mixElements.add((Element)mixData.getAny().get(0));
        Document mixDocument = MetsUtils.getDocumentFromList(mixElements);
            DOMSource mixSource = new DOMSource(mixDocument);
            Mix mix = MixUtils.unmarshal(mixSource, Mix.class);
            assertEquals("ProArc_URI", mix.getBasicDigitalObjectInformation().getObjectIdentifier().get(0).getObjectIdentifierType().getValue());
            assertEquals("JPEG", mix.getBasicDigitalObjectInformation().getCompression().get(0).getCompressionScheme().getValue());
            assertNotNull(mix.getChangeHistory().getImageProcessing().get(0).getDateTimeProcessed().getValue());
        } else
            if ("OBJ_002".equals(techMD.getID())) {
                testObject(techMD, "info:fedora/uuid:2ff2dd0c-d438-4d95-940f-690ee0f44a4a/NDK_ARCHIVAL", "9b0a294cda0508b1a205a57fa66f9568", "MC_creation_001");
            } else if ("OBJ_004".equals(techMD.getID())) {
                testObject(techMD, "info:fedora/uuid:2ff2dd0c-d438-4d95-940f-690ee0f44a4a/NDK_USER", "9b0a294cda0508b1a205a57fa66f9568", "UC_creation_001");
            } else if ("OBJ_005".equals(techMD.getID())) {
                testObject(techMD, "info:fedora/uuid:2ff2dd0c-d438-4d95-940f-690ee0f44a4a/TEXT_OCR", "d41d8cd98f00b204e9800998ecf8427e", "TXT_creation_001");
            } else {
            Assert.fail("Unexpected node:" + techMD.getID());
            }
    }

    List<MdSecType> digiProvList = mets.getAmdSec().get(0).getDigiprovMD();
    assertEquals(4, digiProvList.size());
    for (MdSecType digiProv : digiProvList) {
        if ("EVT_002".equals(digiProv.getID())) {
            testEvent(digiProv, "MC_creation_001", "migration", "migration/MC_creation", "info:fedora/uuid:2ff2dd0c-d438-4d95-940f-690ee0f44a4a/NDK_ARCHIVAL");
        } else if("EVT_004".equals(digiProv.getID())){
            testEvent(digiProv, "UC_creation_001", "derivation", "derivation/UC_creation", "info:fedora/uuid:2ff2dd0c-d438-4d95-940f-690ee0f44a4a/NDK_USER");
        } else if ("EVT_005".equals(digiProv.getID())) {
            testEvent(digiProv, "TXT_creation_001", "capture", "capture/TXT_creation", "info:fedora/uuid:2ff2dd0c-d438-4d95-940f-690ee0f44a4a/TEXT_OCR");
        } else if ("AGENT_001".equals(digiProv.getID())) {
            XmlData premisData = digiProv.getMdWrap().getXmlData();
            DOMSource premisSource = new DOMSource((Node) premisData.getAny().get(0));
            AgentComplexType premisType = PremisUtils.unmarshal(premisSource, AgentComplexType.class);
            assertEquals("ProArc_AgentID", premisType.getAgentIdentifier().get(0).getAgentIdentifierType());
            assertEquals("ProArc", premisType.getAgentIdentifier().get(0).getAgentIdentifierValue());
        } else {
            Assert.fail("Unexpected node:" + digiProv.getID());
        }
    }

    assertEquals(3, mets.getFileSec().getFileGrp().size());
    assertEquals("PHYSICAL", mets.getStructMap().get(0).getTYPE());
    assertEquals("MONOGRAPH_PAGE", mets.getStructMap().get(0).getDiv().getTYPE());
    assertEquals(3, mets.getStructMap().get(0).getDiv().getFptr().size());
}
 
Example 19
@Override
protected void processTable(String tableNameWithType) {
  // Only relocate segments for LLC real-time table
  if (!TableNameBuilder.isRealtimeTableResource(tableNameWithType)) {
    return;
  }
  TableConfig tableConfig = _pinotHelixResourceManager.getTableConfig(tableNameWithType);
  Preconditions.checkState(tableConfig != null, "Failed to find table config for table: {}", tableNameWithType);
  if (new StreamConfig(tableNameWithType, tableConfig.getIndexingConfig().getStreamConfigs())
      .hasHighLevelConsumerType()) {
    return;
  }
  if (!InstanceAssignmentConfigUtils.shouldRelocateCompletedSegments(tableConfig)) {
    LOGGER.debug("No need to relocate COMPLETED segments for table: {}", tableNameWithType);
    return;
  }

  LOGGER.info("Relocating COMPLETED segments for table: {}", tableNameWithType);
  // Allow at most one replica unavailable during relocation
  Configuration rebalanceConfig = new BaseConfiguration();
  rebalanceConfig.addProperty(RebalanceConfigConstants.MIN_REPLICAS_TO_KEEP_UP_FOR_NO_DOWNTIME, -1);
  // Run rebalance asynchronously
  _executorService.submit(() -> {
    try {
      RebalanceResult rebalance =
          new TableRebalancer(_pinotHelixResourceManager.getHelixZkManager()).rebalance(tableConfig, rebalanceConfig);
      switch (rebalance.getStatus()) {
        case NO_OP:
          LOGGER.info("All COMPLETED segments are already relocated for table: {}", tableNameWithType);
          break;
        case DONE:
          LOGGER.info("Finished relocating COMPLETED segments for table: {}", tableNameWithType);
          break;
        default:
          LOGGER.error("Relocation failed for table: {}", tableNameWithType);
      }
    } catch (Throwable t) {
      LOGGER.error("Caught exception/error while rebalancing table: {}", tableNameWithType, t);
    }
  });
}
 
Example 20
Source Project: juddi   File: ClientConfig.java    License: Apache License 2.0 2 votes vote down vote up
private void addXRegistration(Configuration cc) {

                cc.addProperty("client.XtoWsdl.IgnoreSSLErrors", isX_To_Wsdl_Ignore_SSL_Errors());
        }