/** * Gets the default schema name of a given store class */ public static String getDefaultSchemaName(Properties properties, DataStore<?,?> store) { return findProperty(properties, store, SCHEMA_NAME, null); }
/** * Gets the default schema name of a given store class */ public static String getDefaultSchemaName(Properties properties, DataStore<?,?> store) { return findProperty(properties, store, SCHEMA_NAME, null); }
/** * Returns the input path as read from the properties for file-backed data stores. */ public static String getInputPath(Properties properties, DataStore<?,?> store) { return findProperty(properties, store, INPUT_PATH, null); }
/** * Returns the output path as read from the properties for file-backed data stores. */ public static String getOutputPath(Properties properties, DataStore<?,?> store) { return findProperty(properties, store, OUTPUT_PATH, null); }
/** * Returns the input path as read from the properties for file-backed data stores. */ public static String getInputPath(Properties properties, DataStore<?,?> store) { return findProperty(properties, store, INPUT_PATH, null); }
/** * Returns the output path as read from the properties for file-backed data stores. */ public static String getOutputPath(Properties properties, DataStore<?,?> store) { return findProperty(properties, store, OUTPUT_PATH, null); }
public static boolean findBooleanProperty(Properties properties , DataStore<?, ?> store, String baseKey, String defaultValue) { return Boolean.parseBoolean(findProperty(properties, store, baseKey, defaultValue)); }
public static boolean findBooleanProperty(Properties properties , DataStore<?, ?> store, String baseKey, String defaultValue) { return Boolean.parseBoolean(findProperty(properties, store, baseKey, defaultValue)); }
/** * Tries to find a property with the given baseKey. First the property * key constructed as "gora.<classname>.<baseKey>" is searched. * If not found, the property keys for all superclasses is recursively * tested. Lastly, the property key constructed as * "gora.datastore.<baseKey>" is searched. * @return the first found value, or throws IOException */ public static String findPropertyOrDie(Properties properties , DataStore<?, ?> store, String baseKey) throws IOException { String val = findProperty(properties, store, baseKey, null); if(val == null) { throw new IOException("Property with base name \""+baseKey+"\" could not be found, make " + "sure to include this property in gora.properties file"); } return val; }
/** * Tries to find a property with the given baseKey. First the property * key constructed as "gora.<classname>.<baseKey>" is searched. * If not found, the property keys for all superclasses is recursively * tested. Lastly, the property key constructed as * "gora.datastore.<baseKey>" is searched. * @return the first found value, or throws IOException */ public static String findPropertyOrDie(Properties properties , DataStore<?, ?> store, String baseKey) throws IOException { String val = findProperty(properties, store, baseKey, null); if(val == null) { throw new IOException("Property with base name \""+baseKey+"\" could not be found, make " + "sure to include this property in gora.properties file"); } return val; }
/** * Looks for the <code>gora-<classname>-mapping.xml</code> as a resource * on the classpath. This can however also be specified within the * <code>gora.properties</code> file with the key * <code>gora.<classname>.mapping.file=</code>. * @param properties which hold keys from which we can obtain values for datastore mappings. * @param store {@link org.apache.gora.store.DataStore} object to get the mapping for. * @param defaultValue default value for the <code>gora-<classname>-mapping.xml</code> * @return mappingFilename if one is located. * @throws IOException if there is a problem reading or obtaining the mapping file. */ public static String getMappingFile(Properties properties, DataStore<?,?> store , String defaultValue) throws IOException { String mappingFilename = findProperty(properties, store, MAPPING_FILE, defaultValue); InputStream mappingFile = store.getClass().getClassLoader().getResourceAsStream(mappingFilename); if (mappingFile == null) throw new IOException("Unable to open mapping file: "+mappingFilename); mappingFile.close(); return mappingFilename; }
/** * Looks for the <code>gora-<classname>-mapping.xml</code> as a resource * on the classpath. This can however also be specified within the * <code>gora.properties</code> file with the key * <code>gora.<classname>.mapping.file=</code>. * @param properties which hold keys from which we can obtain values for datastore mappings. * @param store {@link org.apache.gora.store.DataStore} object to get the mapping for. * @param defaultValue default value for the <code>gora-<classname>-mapping.xml</code> * @return mappingFilename if one is located. * @throws IOException if there is a problem reading or obtaining the mapping file. */ public static String getMappingFile(Properties properties, DataStore<?,?> store , String defaultValue) throws IOException { String mappingFilename = findProperty(properties, store, MAPPING_FILE, defaultValue); InputStream mappingFile = store.getClass().getClassLoader().getResourceAsStream(mappingFilename); if (mappingFile == null) throw new IOException("Unable to open mapping file: "+mappingFilename); mappingFile.close(); return mappingFilename; }
/** * Initialize is called when then the call to * {@link org.apache.gora.store.DataStoreFactory#createDataStore(Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistent, org.apache.hadoop.conf.Configuration conf)} * is made. In this case, we merely delegate the store initialization to the * {@link org.apache.gora.cassandra.store.CassandraClient#initialize(Class<K> keyClass, Class<T> persistentClass)}. */ public void initialize(Class<K> keyClass, Class<T> persistent, Properties properties) { try { super.initialize(keyClass, persistent, properties); if (autoCreateSchema) { // If this is not set, then each Cassandra client should set its default // column family colFamConsLvl = DataStoreFactory.findProperty(properties, this, COL_FAM_CL, null); // operations readOpConsLvl = DataStoreFactory.findProperty(properties, this, READ_OP_CL, null); writeOpConsLvl = DataStoreFactory.findProperty(properties, this, WRITE_OP_CL, null); } this.cassandraClient.initialize(keyClass, persistent); } catch (Exception e) { LOG.error(e.getMessage()); LOG.error(e.getStackTrace().toString()); } }
@Override public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) { super.initialize(keyClass, persistentClass, properties); if(properties != null && this.codecType == null) { String codecType = DataStoreFactory.findProperty( properties, this, CODEC_TYPE_KEY, "BINARY"); this.codecType = CodecType.valueOf(codecType); } }
@Override public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException { super.initialize(keyClass, persistentClass, properties); if(properties != null && this.codecType == null) { String codecType = DataStoreFactory.findProperty( properties, this, CODEC_TYPE_KEY, "BINARY"); this.codecType = CodecType.valueOf(codecType); } }
String mock = DataStoreFactory.findProperty(properties, this, MOCK_PROPERTY, null); String mappingFile = DataStoreFactory.getMappingFile(properties, this, DEFAULT_MAPPING_FILE); String user = DataStoreFactory.findProperty(properties, this, USERNAME_PROPERTY, null); String password = DataStoreFactory.findProperty(properties, this, PASSWORD_PROPERTY, null); String instance = DataStoreFactory.findProperty(properties, this, INSTANCE_NAME_PROPERTY, null); String zookeepers = DataStoreFactory.findProperty(properties, this, ZOOKEEPERS_NAME_PROPERTY, null); conn = new ZooKeeperInstance(instance, zookeepers).getConnector(user, token); } else {
Integer.valueOf(DataStoreFactory.findProperty(this.properties, this, SCANNER_CACHING_PROPERTIES_KEY, String.valueOf(SCANNER_CACHING_PROPERTIES_DEFAULT)))) ;
@Test public void testFindProperty() { Properties properties = DataStoreFactory.createProps(); DataStore<String, MockPersistent> store = new DataFileAvroStore<>(); String fooValue = DataStoreFactory.findProperty(properties, store, "foo_property", "foo_default"); assertEquals("foo_value", fooValue); String bazValue = DataStoreFactory.findProperty(properties, store, "baz_property", "baz_default"); assertEquals("baz_value", bazValue); String barValue = DataStoreFactory.findProperty(properties, store, "bar_property", "bar_default"); assertEquals("bar_value", barValue); String capValue = DataStoreFactory.findProperty(properties, store, "cap_property", "cap_default"); assertEquals("cap_value", capValue); String secondCapValue = DataStoreFactory.findProperty(properties, store, "CAP_property", "cap_default"); assertEquals("cap_value", secondCapValue); }
SolrClientUrl = DataStoreFactory.findProperty(properties, this, SOLR_URL_PROPERTY, null); solrConfig = DataStoreFactory.findProperty(properties, this, SOLR_CONFIG_PROPERTY, null); solrSchema = DataStoreFactory.findProperty(properties, this, SOLR_SCHEMA_PROPERTY, null); solrJServerImpl = DataStoreFactory.findProperty(properties, this, SOLR_SOLRJSERVER_IMPL, "http"); serverUserAuth = DataStoreFactory.findBooleanProperty(properties, this, SOLR_SERVER_USER_AUTH, "false"); if (serverUserAuth) { serverUsername = DataStoreFactory.findProperty(properties, this, SOLR_SERVER_USERNAME, null); serverPassword = DataStoreFactory.findProperty(properties, this, SOLR_SERVER_PASSWORD, null); String batchSizeString = DataStoreFactory.findProperty(properties, this, SOLR_BATCH_SIZE_PROPERTY, null); if (batchSizeString != null) { String commitWithinString = DataStoreFactory.findProperty(properties, this, SOLR_COMMIT_WITHIN_PROPERTY, null); if (commitWithinString != null) { String resultsSizeString = DataStoreFactory.findProperty(properties, this, SOLR_RESULTS_SIZE_PROPERTY, null); if (resultsSizeString != null) {
Integer.valueOf(DataStoreFactory.findProperty(this.properties, this, SCANNER_CACHING_PROPERTIES_KEY, String.valueOf(SCANNER_CACHING_PROPERTIES_DEFAULT)))) ;