本文整理汇总了Java中org.sdnplatform.sync.internal.store.IStore类的典型用法代码示例。如果您正苦于以下问题:Java IStore类的具体用法?Java IStore怎么用?Java IStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IStore类属于org.sdnplatform.sync.internal.store包,在下文中一共展示了IStore类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DefaultStoreClient
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
public DefaultStoreClient(IStore<K, V> delegate,
IInconsistencyResolver<Versioned<V>> resolver,
AbstractSyncManager syncManager,
Class<K> keyClass,
TypeReference<K> keyType) {
super();
this.delegate = delegate;
this.syncManager = syncManager;
this.keyClass = keyClass;
this.keyType = keyType;
IInconsistencyResolver<Versioned<V>> vcir =
new VectorClockInconsistencyResolver<V>();
IInconsistencyResolver<Versioned<V>> secondary = resolver;
if (secondary == null)
secondary = new TimeBasedInconsistencyResolver<V>();
this.resolver = new ChainedResolver<Versioned<V>>(vcir, secondary);
}
示例2: testGetVersions
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
@Test
public void testGetVersions() throws Exception {
List<K> keys = getKeys(2);
K key = keys.get(0);
V value = getValue();
IStore<K, V> store = getStore();
store.put(key, Versioned.value(value));
List<Versioned<V>> versioneds = store.get(key);
List<IVersion> versions = store.getVersions(key);
assertEquals(1, versioneds.size());
assertTrue(versions.size() > 0);
for(int i = 0; i < versions.size(); i++)
assertEquals(versioneds.get(0).getVersion(), versions.get(i));
assertEquals(0, store.getVersions(keys.get(1)).size());
}
示例3: DefaultStoreClient
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public DefaultStoreClient(IStore<K, V> delegate,
IInconsistencyResolver<Versioned<V>> resolver,
AbstractSyncManager syncManager,
Class<K> keyClass,
TypeReference<K> keyType) {
super();
this.delegate = delegate;
this.syncManager = syncManager;
this.keyClass = keyClass;
this.keyType = keyType;
IInconsistencyResolver<Versioned<V>> vcir =
new VectorClockInconsistencyResolver<V>();
IInconsistencyResolver<Versioned<V>> secondary = resolver;
if (secondary == null)
secondary = new TimeBasedInconsistencyResolver<V>();
this.resolver = new ChainedResolver<Versioned<V>>(vcir, secondary);
}
示例4: newCursor
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
/**
* Allocate a new cursor for the given store name
* @param storeName the store name
* @return the {@link Cursor}
* @throws SyncException
*/
public Cursor newCursor(String storeName) throws UnknownStoreException {
IStore<ByteArray, byte[]> store = getStore(storeName);
int cursorId = rpcService.getTransactionId();
Cursor cursor = new Cursor(cursorId, store.entries());
cursorMap.put(Integer.valueOf(cursorId), cursor);
return cursor;
}
示例5: getStoreClient
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
/**
* The "real" version of getStoreClient that will be called by all
* the others
* @param storeName the store name
* @param keyClass the key class
* @param keyType the key type
* @param valueClass the value class
* @param valueType the value type
* @param resolver the inconsistency resolver
* @return a {@link DefaultStoreClient} using the given parameters.
* @throws UnknownStoreException
*/
public <K, V> IStoreClient<K, V>
getStoreClient(String storeName,
Class<K> keyClass,
TypeReference<K> keyType,
Class<V> valueClass,
TypeReference<V> valueType,
IInconsistencyResolver<Versioned<V>> resolver)
throws UnknownStoreException {
IStore<ByteArray,byte[]> store = getStore(storeName);
IStore<K, V> serializingStore;
if (valueType != null && keyType != null) {
serializingStore =
new JacksonStore<K, V>(store, keyType, valueType);
} else if (valueClass != null && keyClass != null) {
serializingStore =
new JacksonStore<K, V>(store, keyClass, valueClass);
} else {
throw new IllegalArgumentException("Must include type reference" +
" or value class");
}
DefaultStoreClient<K, V> storeClient =
new DefaultStoreClient<K, V>(serializingStore,
resolver,
this,
keyClass,
keyType);
return storeClient;
}
示例6: testEmptyByteArray
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
@Test
public void testEmptyByteArray() throws Exception {
IStore<ByteArray, byte[]> store = getStore();
Versioned<byte[]> bytes = new Versioned<byte[]>(new byte[0]);
store.put(new ByteArray(new byte[0]), bytes);
List<Versioned<byte[]>> found = store.get(new ByteArray(new byte[0]));
assertEquals("Incorrect number of results.", 1, found.size());
bassertEquals("Get doesn't equal put.", bytes, found.get(0));
}
示例7: testPutNullValue
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
@Test
public void testPutNullValue() throws Exception {
IStore<K,V> store = getStore();
K key = getKey();
store.put(key, new Versioned<V>(null));
List<Versioned<V>> found = store.get(key);
assertEquals("Wrong number of values.", 1, found.size());
assertEquals("Returned non-null value.", null,
found.get(0).getValue());
}
示例8: testGetAndDeleteNonExistentKey
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
@Test
public void testGetAndDeleteNonExistentKey() throws Exception {
K key = getKey();
IStore<K, V> store = getStore();
List<Versioned<V>> found = store.get(key);
assertEquals("Found non-existent key: " + found, 0, found.size());
}
示例9: testObsoletePutFails
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
private void testObsoletePutFails(String message,
IStore<K, V> store,
K key,
Versioned<V> versioned) throws SyncException {
VectorClock clock = (VectorClock) versioned.getVersion();
clock = clock.clone();
try {
store.put(key, versioned);
fail(message);
} catch(ObsoleteVersionException e) {
// this is good, but check that we didn't fuck with the version
assertEquals(clock, versioned.getVersion());
}
}
示例10: testFetchedEqualsPut
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
@Test
public void testFetchedEqualsPut() throws Exception {
K key = getKey();
IStore<K, V> store = getStore();
VectorClock clock = getClock(1, 1, 2, 3, 3, 4);
V value = getValue();
assertEquals("Store not empty at start!", 0, store.get(key).size());
Versioned<V> versioned = new Versioned<V>(value, clock);
store.put(key, versioned);
List<Versioned<V>> found = store.get(key);
assertEquals("Should only be one version stored.", 1, found.size());
assertTrue("Values not equal!", valuesEqual(versioned.getValue(), found.get(0).getValue()));
}
示例11: testCloseIsIdempotent
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
@Test
public void testCloseIsIdempotent() throws Exception {
IStore<K, V> store = getStore();
store.close();
// second close is okay, should not throw an exception
store.close();
}
示例12: getStore
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
@Override
public IStore<Key, TBean> getStore() throws Exception {
IStore<ByteArray,byte[]> ims =
new InMemoryStorageEngine<ByteArray,byte[]>("test");
IStore<Key,TBean> js =
new JacksonStore<Key, TBean>(ims, Key.class, TBean.class);
return js;
}
示例13: newCursor
import org.sdnplatform.sync.internal.store.IStore; //导入依赖的package包/类
/**
* Allocate a new cursor for the given store name
* @param storeName the store name
* @return the {@link Cursor}
* @throws SyncException
*/
public Cursor newCursor(String storeName) throws UnknownStoreException {
IStore<ByteArray, byte[]> store = getStore(storeName);
int cursorId = rpcService.getTransactionId();
Cursor cursor = new Cursor(cursorId, store.entries());
cursorMap.put(Integer.valueOf(cursorId), cursor);
return cursor;
}