当前位置: 首页>>代码示例>>Java>>正文


Java GoraException类代码示例

本文整理汇总了Java中org.apache.gora.util.GoraException的典型用法代码示例。如果您正苦于以下问题:Java GoraException类的具体用法?Java GoraException怎么用?Java GoraException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GoraException类属于org.apache.gora.util包,在下文中一共展示了GoraException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromBytes

import org.apache.gora.util.GoraException; //导入依赖的package包/类
public Object fromBytes(Schema schema, byte data[]) throws GoraException {
  Schema fromSchema = null;
  if (schema.getType() == Type.UNION) {
    try {
      Decoder decoder = DecoderFactory.get().binaryDecoder(data, null);
      int unionIndex = decoder.readIndex();
      List<Schema> possibleTypes = schema.getTypes();
      fromSchema = possibleTypes.get(unionIndex);
      Schema effectiveSchema = possibleTypes.get(unionIndex);
      if (effectiveSchema.getType() == Type.NULL) {
        decoder.readNull();
        return null;
      } else {
        data = decoder.readBytes(null).array();
      }
    } catch (IOException e) {
      LOG.error(e.getMessage());
      throw new GoraException("Error decoding union type: ", e);
    }
  } else {
    fromSchema = schema;
  }
  return fromBytes(encoder, fromSchema, data);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:25,代码来源:AccumuloStore.java

示例2: HBaseFilterUtil

import org.apache.gora.util.GoraException; //导入依赖的package包/类
public HBaseFilterUtil(Configuration conf) throws GoraException {
  String[] factoryClassNames = conf.getStrings("gora.hbase.filter.factories", "org.apache.gora.hbase.util.DefaultFactory");

  for (String factoryClass : factoryClassNames) {
    try {
      @SuppressWarnings("unchecked")
      FilterFactory<K, T> factory = (FilterFactory<K, T>) ReflectionUtils.newInstance(factoryClass);
      for (String filterClass : factory.getSupportedFilters()) {
        factories.put(filterClass, factory);
      }
      factory.setHBaseFitlerUtil(this);
    } catch (Exception e) {
      throw new GoraException(e);
    }
  }
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:17,代码来源:HBaseFilterUtil.java

示例3: MongoFilterUtil

import org.apache.gora.util.GoraException; //导入依赖的package包/类
public MongoFilterUtil(final Configuration conf) throws GoraException {
  String[] factoryClassNames = conf.getStrings(
      MONGO_FILTER_FACTORIES_PARAMETER, MONGO_FILTERS_DEFAULT_FACTORY);

  for (String factoryClass : factoryClassNames) {
    try {
      FilterFactory<K, T> factory = (FilterFactory<K, T>) ReflectionUtils
          .newInstance(factoryClass);
      for (String filterClass : factory.getSupportedFilters()) {
        factories.put(filterClass, factory);
      }
      factory.setFilterUtil(this);
    } catch (Exception e) {
      throw new GoraException(e);
    }
  }
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:18,代码来源:MongoFilterUtil.java

示例4: fromBytes

import org.apache.gora.util.GoraException; //导入依赖的package包/类
public Object fromBytes(Schema schema, byte[] data) throws IOException {
  Schema fromSchema = null;
  if (schema.getType() == Type.UNION) {
    try {
      Decoder decoder = DecoderFactory.get().binaryDecoder(data, null);
      int unionIndex = decoder.readIndex();
      List<Schema> possibleTypes = schema.getTypes();
      fromSchema = possibleTypes.get(unionIndex);
      Schema effectiveSchema = possibleTypes.get(unionIndex);
      if (effectiveSchema.getType() == Type.NULL) {
        decoder.readNull();
        return null;
      } else {
        data = decoder.readBytes(null).array();
      }
    } catch (IOException e) {
      LOG.error(e.getMessage());
      throw new GoraException("Error decoding union type: ", e);
    }
  } else {
    fromSchema = schema;
  }
  return fromBytes(encoder, fromSchema, data);
}
 
开发者ID:apache,项目名称:gora,代码行数:25,代码来源:AccumuloStore.java

示例5: put

import org.apache.gora.util.GoraException; //导入依赖的package包/类
/**
 * Puts an object identified by a key
 *
 * @param key
 * @param obj
 */
@Override
public void put(K key, T obj) {
  try {
    Object hashKey = getHashKey(key, obj);
    Object rangeKey = getRangeKey(key, obj);
    if (hashKey != null) {
      DynamoDBMapper mapper = new DynamoDBMapper(
          dynamoDBStoreHandler.getDynamoDbClient());
      if (rangeKey != null) {
        mapper.load(persistentClass, hashKey, rangeKey);
      } else {
        mapper.load(persistentClass, hashKey);
      }
      mapper.save(obj);
    } else
      throw new GoraException("No HashKey found in Key nor in Object.");
  } catch (NullPointerException npe) {
    LOG.error("Error while putting an item. " + npe.toString());
    throw new NullArgumentException(npe.getMessage());
  } catch (Exception e) {
    LOG.error("Error while putting an item. " + obj.toString());
    throw new RuntimeException(e);
  }
}
 
开发者ID:apache,项目名称:gora,代码行数:31,代码来源:DynamoDBNativeStore.java

示例6: getDataStore

import org.apache.gora.util.GoraException; //导入依赖的package包/类
/**
 * Instantiate <i>the default</i> {@link DataStore} wrapped over caching dataStore which provides caching
 * abstraction over the GORA persistence 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.
 * @param isCacheEnabled Caching enable or not.
 * @return A new store instance.
 * @throws GoraException If cache or persistency dataStore initialization interrupted.
 */
@SuppressWarnings("unchecked")
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));
    }
  } catch (Exception ex) {
    throw new GoraException(ex);
  }
  return createDataStore(c, keyClass, persistent, conf, createProps, null);
}
 
开发者ID:apache,项目名称:gora,代码行数:32,代码来源:DataStoreFactory.java

示例7: putMap

import org.apache.gora.util.GoraException; //导入依赖的package包/类
private int putMap(Mutation m, int count, Schema valueType, Object o, Pair<Text, Text> col, String fieldName) throws GoraException {

    // First of all we delete map field on accumulo store
    Text rowKey = new Text(m.getRow());
    Query<K, T> query = newQuery();
    query.setFields(fieldName);
    query.setStartKey((K)rowKey.toString());
    query.setEndKey((K)rowKey.toString());
    deleteByQuery(query);
    flush();
    if (o == null){
      return 0;
    }

    Set<?> es = ((Map<?, ?>)o).entrySet();
    for (Object entry : es) {
      Object mapKey = ((Entry<?, ?>) entry).getKey();
      Object mapVal = ((Entry<?, ?>) entry).getValue();
      if ((o instanceof DirtyMapWrapper && ((DirtyMapWrapper<?, ?>)o).isDirty())
          || !(o instanceof DirtyMapWrapper)) { //mapVal instanceof Dirtyable && ((Dirtyable)mapVal).isDirty()) {
        m.put(col.getFirst(), new Text(toBytes(mapKey)), new Value(toBytes(valueType, mapVal)));
        count++;
      }
      // TODO map value deletion
    }
    return count;
  }
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:28,代码来源:AccumuloStore.java

示例8: put

import org.apache.gora.util.GoraException; //导入依赖的package包/类
/**
 * Puts an object identified by a key
 * @throws IOException
 */
@Override
public void put(K key, T obj) {
  try{
    Object rangeKey = getRangeKey(key);
    Object hashKey = getHashKey(key);
    // if the key does not have these attributes then try to get them from the object
    if (hashKey == null)
      hashKey = getHashKey(obj);
    if (rangeKey == null)
      rangeKey = getRangeKey(obj);
    if (hashKey != null){
      DynamoDBMapper mapper = new DynamoDBMapper(dynamoDBClient);
      if (rangeKey != null)
        mapper.load(persistentClass, hashKey.toString(), rangeKey.toString());
      else
        mapper.load(persistentClass, hashKey.toString());
        mapper.save(obj);
    }
    else
      throw new GoraException("Error while retrieving keys from object: " + obj.toString());
  }catch(NullPointerException npe){
    LOG.error("Error while putting an item. " + npe.toString());
    npe.printStackTrace();
  }catch(Exception e){
    LOG.error("Error while putting an item. " + obj.toString());
    e.printStackTrace();
  }
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:33,代码来源:DynamoDBStore.java

示例9: createDataStore

import org.apache.gora.util.GoraException; //导入依赖的package包/类
/**
 * Creates the DynamoDB store but returns a generic object
 */
@SuppressWarnings("unchecked")
public<K, T extends Persistent> DataStore<K,T>
  createDataStore(Class<K> keyClass, Class<T> persistentClass) throws GoraException {
    personStore = (DynamoDBStore<DynamoDBKey, person>) WSDataStoreFactory.createDataStore(
      (Class<? extends DataStore<K,T>>)dataStoreClass, keyClass, persistentClass, auth);
    dataStores.add(personStore);
  return (DataStore<K, T>) personStore;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:12,代码来源:GoraDynamoDBTestDriver.java

示例10: getDataStore

import org.apache.gora.util.GoraException; //导入依赖的package包/类
/**
 * Instantiate <i>the default</i> {@link DataStore}. Uses default properties. Uses 'null' schema.
 * 
 * @param keyClass The key class.
 * @param persistent The value class.
 * @param auth an authentication {@link Object} to be used for communication.
 * @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, Object auth) 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, auth, createProps, null);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:22,代码来源:WSDataStoreFactory.java

示例11: getDataStore

import org.apache.gora.util.GoraException; //导入依赖的package包/类
/**
 * Instantiate <i>the default</i> {@link DataStore}. Uses default properties. Uses 'null' schema.
 * 
 * @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);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:22,代码来源:DataStoreFactory.java

示例12: get

import org.apache.gora.util.GoraException; //导入依赖的package包/类
public static MockDataStore get() {
  MockDataStore dataStore;
  try {
    dataStore = DataStoreFactory.getDataStore(MockDataStore.class
        , String.class, MockPersistent.class, new Configuration());
    return dataStore;
  } catch (GoraException ex) {
    throw new RuntimeException(ex);
  }
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:11,代码来源:MockDataStore.java

示例13: createDataStore

import org.apache.gora.util.GoraException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public<K, T extends Persistent> DataStore<K,T>
  createDataStore(Class<K> keyClass, Class<T> persistentClass) throws GoraException {
  setProperties(DataStoreFactory.createProps());
  DataStore<K,T> dataStore = DataStoreFactory.createDataStore(
      (Class<? extends DataStore<K,T>>)dataStoreClass, keyClass, persistentClass, conf);
  dataStores.add(dataStore);

  log.info("Datastore for "+persistentClass+" was added.");
  return dataStore;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:12,代码来源:GoraTestDriver.java

示例14: testGetDataStore

import org.apache.gora.util.GoraException; //导入依赖的package包/类
@Test
public void testGetDataStore() throws GoraException {
  DataStore<?, ?> dataStore = DataStoreFactory.getDataStore(
      "org.apache.gora.mock.store.MockDataStore", String.class,
      MockPersistent.class, conf);
  assertNotNull(dataStore);
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:8,代码来源:TestDataStoreFactory.java

示例15: testGetClasses

import org.apache.gora.util.GoraException; //导入依赖的package包/类
@Test
public void testGetClasses() throws GoraException {
  DataStore<?, ?> dataStore = DataStoreFactory.getDataStore(
      "org.apache.gora.mock.store.MockDataStore", String.class,
      MockPersistent.class, conf);
  assertNotNull(dataStore);
  assertEquals(String.class, dataStore.getKeyClass());
  assertEquals(MockPersistent.class, dataStore.getPersistentClass());
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:10,代码来源:TestDataStoreFactory.java


注:本文中的org.apache.gora.util.GoraException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。