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


Java IStoreClient.put方法代码示例

本文整理汇总了Java中org.sdnplatform.sync.IStoreClient.put方法的典型用法代码示例。如果您正苦于以下问题:Java IStoreClient.put方法的具体用法?Java IStoreClient.put怎么用?Java IStoreClient.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sdnplatform.sync.IStoreClient的用法示例。


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

示例1: testBasicGlobalSync

import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
@Test
public void testBasicGlobalSync() throws Exception {
    waitForFullMesh(2000);

    ArrayList<IStoreClient<String, String>> clients =
            new ArrayList<IStoreClient<String, String>>(syncManagers.length);
    // write one value to each node's local interface
    for (int i = 0; i < syncManagers.length; i++) {
        IStoreClient<String, String> client =
                syncManagers[i].getStoreClient("global", 
                                               String.class, String.class);
        clients.add(client);
        client.put("key" + i, ""+i);
    }

    // verify that we see all the values everywhere
    for (int j = 0; j < clients.size(); j++) {
        for (int i = 0; i < syncManagers.length; i++) {
            waitForValue(clients.get(j), "key" + i, ""+i, 2000, "client"+j);
        }
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:SyncManagerTest.java

示例2: testBasicOneNode

import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
@Test
public void testBasicOneNode() throws Exception {
    AbstractSyncManager sync = syncManagers[0];
    IStoreClient<Key, TBean> testClient =
            sync.getStoreClient("global", Key.class, TBean.class);
    Key k = new Key("com.bigswitch.bigsync.internal", "test");
    TBean tb = new TBean("hello", 42);
    TBean tb2 = new TBean("hello", 84);
    TBean tb3 = new TBean("hello", 126);
    
    assertNotNull(testClient.get(k));
    assertNull(testClient.get(k).getValue());
    
    testClient.put(k, tb);
    Versioned<TBean> result = testClient.get(k);
    assertEquals(result.getValue(), tb);

    result.setValue(tb2);
    testClient.put(k, result);

    try {
        result.setValue(tb3);
        testClient.put(k, result);
        fail("Should get ObsoleteVersionException");
    } catch (ObsoleteVersionException e) {
        // happy town
    }

    result = testClient.get(k);
    assertEquals(tb2, result.getValue());
    
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:33,代码来源:SyncManagerTest.java

示例3: testIterator

import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
@Test
public void testIterator() throws Exception {
    AbstractSyncManager sync = syncManagers[0];
    IStoreClient<Key, TBean> testClient =
            sync.getStoreClient("local", Key.class, TBean.class);
    
    HashMap<Key, TBean> testMap = new HashMap<Key, TBean>();
    for (int i = 0; i < 100; i++) {
        Key k = new Key("com.bigswitch.bigsync.internal", "test" + i);
        TBean tb = new TBean("value", i);
        testMap.put(k, tb);
        testClient.put(k, tb);
    }
    
    IClosableIterator<Entry<Key, Versioned<TBean>>> iter = 
            testClient.entries();
    int size = 0;
    try {
        while (iter.hasNext()) {
            Entry<Key, Versioned<TBean>> e = iter.next();
            assertEquals(testMap.get(e.getKey()), e.getValue().getValue());
            size += 1;
        }
    } finally {
        iter.close();
    }
    assertEquals(testMap.size(), size);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:SyncManagerTest.java

示例4: testRemoveNode

import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
@Test
public void testRemoveNode() throws Exception {
    waitForFullMesh(2000);
    IStoreClient<String, String> client0 =
            syncManagers[0].getStoreClient("global", 
                                           String.class, String.class);
    IStoreClient<String, String> client1 =
            syncManagers[1].getStoreClient("global", 
                                           String.class, String.class);
    IStoreClient<String, String> client2 =
            syncManagers[2].getStoreClient("global", 
                                           String.class, String.class);

    client0.put("key", "value");
    waitForValue(client1, "key", "value", 2000, "client1");
    
    nodes.remove(0);
    nodeString = mapper.writeValueAsString(nodes);

    SyncManager oldNode = syncManagers[0];
    syncManagers = Arrays.copyOfRange(syncManagers, 1, 4);
    moduleContexts = Arrays.copyOfRange(moduleContexts, 1, 4);

    try {
        for(int i = 0; i < syncManagers.length; i++) {
            moduleContexts[i].addConfigParam(syncManagers[i],
                                             "nodes", nodeString);
            syncManagers[i].doUpdateConfiguration();
            waitForConnection(syncManagers[i], (short)1, false, 2000);
        }
    } finally {
        oldNode.shutdown();
    }
    waitForFullMesh(2000);

    client1.put("newkey", "newvalue");
    waitForValue(client2, "key", "value", 2000, "client4");
    waitForValue(client2, "newkey", "newvalue", 2000, "client0");
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:40,代码来源:SyncManagerTest.java

示例5: testChangeNode

import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
@Test
public void testChangeNode() throws Exception {
    waitForFullMesh(2000);
    IStoreClient<String, String> client0 =
            syncManagers[0].getStoreClient("global", 
                                           String.class, String.class);
    IStoreClient<String, String> client2 =
            syncManagers[2].getStoreClient("global", 
                                           String.class, String.class);
    client0.put("key", "value");
    waitForValue(client2, "key", "value", 2000, "client2");

    nodes.set(2, new Node("localhost", 50103, (short)3, (short)1));
    nodeString = mapper.writeValueAsString(nodes);

    for(int i = 0; i < syncManagers.length; i++) {
        moduleContexts[i].addConfigParam(syncManagers[i],
                                         "nodes", nodeString);
        syncManagers[i].doUpdateConfiguration();
    }
    waitForFullMesh(2000);
    
    waitForValue(client2, "key", "value", 2000, "client2");
    client2 = syncManagers[2].getStoreClient("global", 
                                             String.class, String.class);
    client0.put("key", "newvalue");
    waitForValue(client2, "key", "newvalue", 2000, "client2");
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:29,代码来源:SyncManagerTest.java

示例6: testSimpleWritePerformance

import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
/**
 * Do a brain-dead performance test with one thread writing and waiting
 * for the values on the other node.  The result get printed to the log
 */
public void testSimpleWritePerformance(String store) throws Exception {
    waitForFullMesh(5000);
    
    final int count = 1000000;

    IStoreClient<String, String> client0 =
            syncManagers[0].getStoreClient(store, 
                                           String.class, String.class);
    IStoreClient<String, String> client2 =
            syncManagers[2].getStoreClient(store, 
                                           String.class, String.class);
    
    long then = System.currentTimeMillis();
    
    for (int i = 1; i <= count; i++) {
        client0.put(""+i, ""+i);
    }

    long donewriting = System.currentTimeMillis();

    waitForValue(client2, ""+count, null, count, "client2");
    
    long now = System.currentTimeMillis();
    
    logger.info("Simple write ({}): {} values in {}+/-100 " +
                "millis ({} synced writes/s) ({} local writes/s)",
                new Object[]{store, count, (now-then), 
                             1000.0*count/(now-then),
                             1000.0*count/(donewriting-then)});

}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:36,代码来源:SyncManagerTest.java

示例7: testReconnect

import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
@Test
public void testReconnect() throws Exception {
    IStoreClient<String, String> client0 =
            syncManagers[0].getStoreClient("global", 
                                           String.class, 
                                           String.class);
    IStoreClient<String, String> client1 =
            syncManagers[1].getStoreClient("global", 
                                           String.class, String.class);
    IStoreClient<String, String> client2 =
            syncManagers[2].getStoreClient("global", 
                                           String.class, String.class);

    client0.put("key0", "value0");
    waitForValue(client2, "key0", "value0", 1000, "client0");

    logger.info("Shutting down server ID 1");
    syncManagers[0].shutdown();
    
    client1.put("newkey1", "newvalue1");
    client2.put("newkey2", "newvalue2");
    client1.put("key0", "newvalue0");
    client2.put("key2", "newvalue2");
    
    for (int i = 0; i < 500; i++) {
        client2.put("largetest" + i, "largetestvalue");
    }
    
    logger.info("Initializing server ID 1");
    syncManagers[0] = new SyncManager();
    setupSyncManager(moduleContexts[0], syncManagers[0], nodes.get(0));

    waitForFullMesh(2000);

    client0 = syncManagers[0].getStoreClient("global", 
                                             String.class, String.class);
    waitForValue(client0, "newkey1", "newvalue1", 1000, "client0");
    waitForValue(client0, "newkey2", "newvalue2", 1000, "client0");
    waitForValue(client0, "key0", "newvalue0", 1000, "client0");
    waitForValue(client0, "key2", "newvalue2", 1000, "client0");

    for (int i = 0; i < 500; i++) {
        waitForValue(client0, "largetest" + i, 
                     "largetestvalue", 1000, "client0");
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:47,代码来源:SyncManagerTest.java

示例8: testNotify

import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
@Test
public void testNotify() throws Exception {
    IStoreClient<String, String> client0 =
            syncManagers[0].getStoreClient("local", 
                                           String.class, String.class);
    IStoreClient<String, String> client2 =
            syncManagers[2].getStoreClient("local", 
                                           new TypeReference<String>() {}, 
                                           new TypeReference<String>() {});
    
    TestListener t0 = new TestListener();
    TestListener t2 = new TestListener();
    client0.addStoreListener(t0);
    client2.addStoreListener(t2);
    
    client0.put("test0", "value");
    client2.put("test2", "value");

    HashSet<Update> c0 = new HashSet<Update>();
    c0.add(new Update("test0", UpdateType.LOCAL));
    c0.add(new Update("test2", UpdateType.REMOTE));
    HashSet<Update> c2 = new HashSet<Update>();
    c2.add(new Update("test0", UpdateType.REMOTE));
    c2.add(new Update("test2", UpdateType.LOCAL));
    
    waitForNotify(t0, c0, 2000);
    waitForNotify(t2, c2, 2000);
    assertEquals(2, t0.notified.size());
    assertEquals(2, t2.notified.size());
    
    t0.notified.clear();
    t2.notified.clear();
    
    Versioned<String> v0 = client0.get("test0");
    v0.setValue("newvalue");
    client0.put("test0", v0);

    Versioned<String> v2 = client0.get("test2");
    v2.setValue("newvalue");
    client2.put("test2", v2);

    waitForNotify(t0, c0, 2000);
    waitForNotify(t2, c2, 2000);
    assertEquals(2, t0.notified.size());
    assertEquals(2, t2.notified.size());

    t0.notified.clear();
    t2.notified.clear();
    
    client0.delete("test0");
    client2.delete("test2");

    waitForNotify(t0, c0, 2000);
    waitForNotify(t2, c2, 2000);
    assertEquals(2, t0.notified.size());
    assertEquals(2, t2.notified.size());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:58,代码来源:SyncManagerTest.java

示例9: testAddNode

import org.sdnplatform.sync.IStoreClient; //导入方法依赖的package包/类
@Test
public void testAddNode() throws Exception {
    waitForFullMesh(2000);
    IStoreClient<String, String> client0 =
            syncManagers[0].getStoreClient("global", 
                                           String.class, String.class);
    IStoreClient<String, String> client1 =
            syncManagers[1].getStoreClient("global", 
                                           String.class, String.class);
    client0.put("key", "value");
    waitForValue(client1, "key", "value", 2000, "client1");
    
    nodes.add(new Node("localhost", 40105, (short)5, (short)5));
    SyncManager[] sms = Arrays.copyOf(syncManagers, 
                                      syncManagers.length + 1);
    FloodlightModuleContext[] fmcs =
            Arrays.copyOf(moduleContexts,
                          moduleContexts.length + 1);
    sms[syncManagers.length] = new SyncManager();
    fmcs[moduleContexts.length] = new FloodlightModuleContext();
    nodeString = mapper.writeValueAsString(nodes);

    setupSyncManager(fmcs[moduleContexts.length],
                     sms[syncManagers.length],
                     nodes.get(syncManagers.length));
    syncManagers = sms;
    moduleContexts = fmcs;

    for(int i = 0; i < 4; i++) {
        moduleContexts[i].addConfigParam(syncManagers[i],
                                         "nodes", nodeString);
        syncManagers[i].doUpdateConfiguration();
    }
    waitForFullMesh(2000);

    IStoreClient<String, String> client4 =
            syncManagers[4].getStoreClient("global", 
                                           String.class, String.class);
    client4.put("newkey", "newvalue");
    waitForValue(client4, "key", "value", 2000, "client4");
    waitForValue(client0, "newkey", "newvalue", 2000, "client0");
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:43,代码来源:SyncManagerTest.java


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