/** * 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); }
private void init() throws IOException { //Data store objects are created from a factory. It is necessary to //provide the key and value class. The datastore class is optional, //and if not specified it will be read from the properties file dataStore = DataStoreFactory.getDataStore(Long.class, Pageview.class, new Configuration()); }
/** * Instantiate a new {@link DataStore}. Uses default properties. Uses 'null' schema. * * @param dataStoreClass The datastore implementation class. * @param keyClass The key class. * @param persistentClass The value class. * @param conf {@link Configuration} to be used be the store. * @return A new store instance. * @throws GoraException */ public static <D extends DataStore<K,T>, K, T extends Persistent> D getDataStore( Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistentClass, Configuration conf) throws GoraException { return createDataStore(dataStoreClass, keyClass, persistentClass, conf, createProps(), null); }
/** * Instantiate <i>the default</i> {@link DataStore}. Uses default properties. Uses 'null' schema. * * Note: * consider that default dataStore is always visible * * @param keyClass The key class. * @param persistent The value class. * @param conf {@link Configuration} to be used be the store. * @return A new store instance. * @throws GoraException */ @SuppressWarnings("unchecked") public static <K, T extends Persistent> DataStore<K, T> getDataStore( Class<K> keyClass, Class<T> persistent, Configuration conf) throws GoraException { Properties createProps = createProps(); Class<? extends DataStore<K, T>> c; try { c = (Class<? extends DataStore<K, T>>) Class.forName(getDefaultDataStore(createProps)); } catch (Exception ex) { throw new GoraException(ex); } return createDataStore(c, keyClass, persistent, conf, createProps, null); }
public static <K, T extends Persistent> DataStore<K, T> getDataStore( Class<K> keyClass, Class<T> persistent, Configuration conf, boolean isCacheEnabled) throws GoraException { Properties createProps = createProps(); Class<? extends DataStore<K, T>> c; try { if (isCacheEnabled) { c = (Class<? extends DataStore<K, T>>) Class.forName(getDefaultCacheDataStore(createProps)); } else { c = (Class<? extends DataStore<K, T>>) Class.forName(getDefaultDataStore(createProps)); return createDataStore(c, keyClass, persistent, conf, createProps, null);
super.initialize(keyClass, persistentClass, properties); try { String mappingFile = DataStoreFactory.getMappingFile(properties, this, DEFAULT_MAPPING_FILE); mapping = readMapping(mappingFile); 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 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 {
@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); }
/** * In initializing the cassandra datastore, read the mapping file, creates the basic connection to cassandra cluster, * according to the gora properties * * @param keyClass key class * @param persistentClass persistent class * @param properties properties */ @Override public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) { LOG.debug("Initializing Cassandra store"); String serializationType; try { this.keyClass = keyClass; this.persistentClass = persistentClass; if (this.beanFactory == null) { this.beanFactory = new BeanFactoryImpl<>(keyClass, persistentClass); } String mappingFile = DataStoreFactory.getMappingFile(properties, this, DEFAULT_MAPPING_FILE); serializationType = properties.getProperty(CassandraStoreParameters.CASSANDRA_SERIALIZATION_TYPE); CassandraMappingBuilder mappingBuilder = new CassandraMappingBuilder(this); mapping = mappingBuilder.readMapping(mappingFile); CassandraClient cassandraClient = new CassandraClient(); cassandraClient.initialize(properties, mapping); cassandraSerializer = CassandraSerializer.getSerializer(cassandraClient, serializationType, this, mapping); } catch (Exception e) { throw new RuntimeException("Error while initializing Cassandra store: " + e.getMessage(), e); } }
/** * Instantiate a new {@link DataStore}. Uses 'null' schema. * * @param dataStoreClass The datastore implementation class. * @param keyClass The key class. * @param persistent The value class. * @param conf {@link Configuration} to be used be the store. * @param properties The properties to be used be the store. * @return A new store instance. * @throws GoraException */ public static <D extends DataStore<K,T>, K, T extends Persistent> D createDataStore(Class<D> dataStoreClass , Class<K> keyClass, Class<T> persistent, Configuration conf, Properties properties) throws GoraException { return createDataStore(dataStoreClass, keyClass, persistent, conf, properties, null); }
@Override protected DataStore<String, WebPage> createWebPageDataStore() throws IOException { DataFileAvroStore<String,WebPage> webPageStore = new DataFileAvroStore<>(); webPageStore.initialize(String.class, WebPage.class, DataStoreFactory.createProps()); webPageStore.setOutputPath(WEBPAGE_OUTPUT); webPageStore.setInputPath(WEBPAGE_OUTPUT); return webPageStore; }
public static boolean getAutoCreateSchema(Properties properties , DataStore<?,?> store) { return findBooleanProperty(properties, store, AUTO_CREATE_SCHEMA, "true"); }
public static <K, T extends Persistent> DataStore<K, T> getDataStore( Class<K> keyClass, Class<T> persistent, Configuration conf, boolean isCacheEnabled) throws GoraException { Properties createProps = createProps(); Class<? extends DataStore<K, T>> c; try { if (isCacheEnabled) { c = (Class<? extends DataStore<K, T>>) Class.forName(getDefaultCacheDataStore(createProps)); } else { c = (Class<? extends DataStore<K, T>>) Class.forName(getDefaultDataStore(createProps)); return createDataStore(c, keyClass, persistent, conf, createProps, null);
this.beanFactory = new BeanFactoryImpl<>(keyClass, persistentClass); String mappingFile = DataStoreFactory.getMappingFile(properties, this, DEFAULT_MAPPING_FILE); serializationType = properties.getProperty(CassandraStoreParameters.CASSANDRA_SERIALIZATION_TYPE); CassandraMappingBuilder mappingBuilder = new CassandraMappingBuilder(this);
/** * Instantiate <i>the default</i> {@link DataStore}. Uses default properties. Uses 'null' schema. * * Note: * consider that default dataStore is always visible * * @param keyClass The key class. * @param persistent The value class. * @param conf {@link Configuration} to be used be the store. * @return A new store instance. * @throws GoraException */ @SuppressWarnings("unchecked") public static <K, T extends Persistent> DataStore<K, T> getDataStore( Class<K> keyClass, Class<T> persistent, Configuration conf) throws GoraException { Properties createProps = createProps(); Class<? extends DataStore<K, T>> c; try { c = (Class<? extends DataStore<K, T>>) Class.forName(getDefaultDataStore(createProps)); } catch (Exception ex) { throw new GoraException(ex); } return createDataStore(c, keyClass, persistent, conf, createProps, null); }
/** * Instantiate a new {@link DataStore}. Uses 'null' schema. * * @param dataStoreClass The datastore implementation class. * @param keyClass The key class. * @param persistent The value class. * @param conf {@link Configuration} to be used be the store. * @param properties The properties to be used be the store. * @return A new store instance. * @throws GoraException */ public static <D extends DataStore<K,T>, K, T extends Persistent> D createDataStore(Class<D> dataStoreClass , Class<K> keyClass, Class<T> persistent, Configuration conf, Properties properties) throws GoraException { return createDataStore(dataStoreClass, keyClass, persistent, conf, properties, null); }
@Before public void setUp() throws Exception { employeeStore = createEmployeeDataStore(); employeeStore.initialize(String.class, Employee.class, DataStoreFactory.createProps()); employeeStore.setOutputPath(EMPLOYEE_OUTPUT); employeeStore.setInputPath(EMPLOYEE_OUTPUT); webPageStore = new AvroStore<>(); webPageStore.initialize(String.class, WebPage.class, DataStoreFactory.createProps()); webPageStore.setOutputPath(WEBPAGE_OUTPUT); webPageStore.setInputPath(WEBPAGE_OUTPUT); }
public static boolean getAutoCreateSchema(Properties properties , DataStore<?,?> store) { return findBooleanProperty(properties, store, AUTO_CREATE_SCHEMA, "true"); }
/** * 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); }
private void init() throws IOException { //Data store objects are created from a factory. It is necessary to //provide the key and value class. The datastore class is optional, //and if not specified it will be read from the properties file //this dataStore talks directly to persistent store dataStore = DataStoreFactory.getDataStore(Long.class, Pageview.class, new Configuration()); //this dataStore talks to persistent store via the cache cacheStore = DataStoreFactory.getDataStore(Long.class, Pageview.class, new Configuration(), true); }