本文整理汇总了Java中org.apache.ignite.internal.util.GridUnsafe.allocateInstance方法的典型用法代码示例。如果您正苦于以下问题:Java GridUnsafe.allocateInstance方法的具体用法?Java GridUnsafe.allocateInstance怎么用?Java GridUnsafe.allocateInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.GridUnsafe
的用法示例。
在下文中一共展示了GridUnsafe.allocateInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* Creates settings for specific table.
*
* @param cacheName Ignite cache name.
* @param tableName Cassandra table name.
* @return settings for target Cassandra table.
*/
private KeyValuePersistenceSettings create(String cacheName, String tableName) {
PublicKeyValuePersistenceSettings keyValue = cacheSettings.get(cacheName);
if (keyValue == null) {
keyValue = new PublicKeyValuePersistenceSettings(null, null, defaultKeySettings, defaultValueSettings);
cacheSettings.put(cacheName, keyValue);
}
try {
Object instance = GridUnsafe.allocateInstance(KeyValuePersistenceSettings.class);
set(instance, elvis(keyValue.getTTL(), generalSettings.getTTL()), "ttl");
set(instance, generalSettings.getKeyspace(), "keyspace");
set(instance, tableName, "tbl");
set(instance, elvis(keyValue.getTableOptions(), generalSettings.getTableOptions()), "tblOptions");
set(instance, generalSettings.getKeyspaceOptions(), "keyspaceOptions");
set(instance, elvis(keyValue.getKeyPersistenceSettings(), defaultKeySettings), "keyPersistenceSettings");
set(instance, elvis(keyValue.getValuePersistenceSettings(), defaultValueSettings), "valPersistenceSettings");
return (KeyValuePersistenceSettings)instance;
}
catch (InstantiationException | NoSuchFieldException | IllegalAccessException e) {
throw new IllegalStateException("Cannot create Settings");
}
}
示例2: readHashSet
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* Reads {@link HashSet}.
*
* @param mapFieldOff Map field offset.
* @return Set.
* @throws ClassNotFoundException If class not found.
* @throws IOException In case of error.
*/
@SuppressWarnings("unchecked")
HashSet<?> readHashSet(long mapFieldOff) throws ClassNotFoundException, IOException {
try {
HashSet<Object> set = (HashSet<Object>)GridUnsafe.allocateInstance(HashSet.class);
handles.assign(set);
setObject(set, mapFieldOff, readHashMap(true));
return set;
}
catch (InstantiationException e) {
throw new IOException(e);
}
}
示例3: readLinkedHashSet
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* Reads {@link LinkedHashSet}.
*
* @param mapFieldOff Map field offset.
* @return Set.
* @throws ClassNotFoundException If class not found.
* @throws IOException In case of error.
*/
@SuppressWarnings("unchecked")
LinkedHashSet<?> readLinkedHashSet(long mapFieldOff) throws ClassNotFoundException, IOException {
try {
LinkedHashSet<Object> set = (LinkedHashSet<Object>)GridUnsafe.allocateInstance(LinkedHashSet.class);
handles.assign(set);
setObject(set, mapFieldOff, readLinkedHashMap(true));
return set;
}
catch (InstantiationException e) {
throw new IOException(e);
}
}
示例4: newInstance
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @return Instance.
* @throws BinaryObjectException In case of error.
*/
private Object newInstance() throws BinaryObjectException {
try {
return ctor != null ? ctor.newInstance() : GridUnsafe.allocateInstance(cls);
}
catch (InstantiationException | InvocationTargetException | IllegalAccessException e) {
throw new BinaryObjectException("Failed to instantiate instance: " + cls, e);
}
}
示例5: allocateInstance0
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param cls Class to create.
* @return Instance of class.
*/
@Nullable protected <T> T allocateInstance0(Class<T> cls) {
try {
return (T)GridUnsafe.allocateInstance(cls);
}
catch (InstantiationException e) {
e.printStackTrace();
return null;
}
}
示例6: allocateInstance
import org.apache.ignite.internal.util.GridUnsafe; //导入方法依赖的package包/类
/**
* @param cls Class to create.
* @return Instance of class.
* @throws Exception If failed.
*/
protected <T> T allocateInstance(Class<T> cls) throws Exception {
return (T)GridUnsafe.allocateInstance(cls);
}