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


Java SyncException类代码示例

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


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

示例1: get

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
@Override
public List<Versioned<byte[]>> get(ByteArray key) throws SyncException {
    StoreUtils.assertValidKey(key);
    GetRequestMessage grm = new GetRequestMessage();

    AsyncMessageHeader header = new AsyncMessageHeader();
    header.setTransactionId(syncManager.getTransactionId());
    grm.setHeader(header);

    grm.setKey(key.get());
    grm.setStoreName(storeName);
    
    SyncMessage bsm = new SyncMessage(MessageType.GET_REQUEST);
    bsm.setGetRequest(grm);

    SyncReply reply = getReply(header.getTransactionId(), bsm);

    return reply.getValues();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:20,代码来源:RemoteStore.java

示例2: put

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
@Override
public IVersion put(K key, V value) throws SyncException {
    List<IVersion> versions = getVersions(key);
    Versioned<V> versioned;
    if(versions.isEmpty())
        versioned = Versioned.value(value, new VectorClock());
    else if(versions.size() == 1)
        versioned = Versioned.value(value, versions.get(0));
    else {
        versioned = get(key, null);
        if(versioned == null)
            versioned = Versioned.value(value, new VectorClock());
        else
            versioned.setValue(value);
    }
    return put(key, versioned);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:18,代码来源:AbstractStoreClient.java

示例3: init

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
private void init(List<Node> nodes, short thisNodeId,
                  AuthScheme authScheme,
                  String keyStorePath, 
                  String keyStorePassword)
        throws SyncException {
    for (Node n : nodes) {
        addNode(n);
    }
    thisNode = getNode(thisNodeId);
    if (thisNode == null) {
        throw new SyncException("Cannot set thisNode " +
                "node: No node with ID " + thisNodeId);
    }
    this.authScheme = authScheme;
    if (this.authScheme == null) 
        this.authScheme = AuthScheme.NO_AUTH;
    this.keyStorePath = keyStorePath;
    this.keyStorePassword = keyStorePassword;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:20,代码来源:ClusterConfig.java

示例4: getValueBytes

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
private byte[] getValueBytes(V value) throws SyncException {
    try {
        byte[] v = null;
        if (valueAsTree)
            v = mapper.writeValueAsBytes(value);
        else
            v = valueWriter.writeValueAsBytes(value);
        
        if (logger.isTraceEnabled()) {
            logger.trace("Converted value {} to {}", 
                         value, Arrays.toString(v));
        }
        return v;
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:JacksonStore.java

示例5: put

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
@Override
public void put(ByteArray key, Versioned<byte[]> value) 
        throws SyncException {
    StoreUtils.assertValidKey(key);
    PutRequestMessage prm = new PutRequestMessage();

    AsyncMessageHeader header = new AsyncMessageHeader();
    header.setTransactionId(syncManager.getTransactionId());
    prm.setHeader(header);
    prm.setVersionedValue(TProtocolUtil.getTVersionedValue(value));
    prm.setKey(key.get());
    prm.setStoreName(storeName);
    
    SyncMessage bsm = new SyncMessage(MessageType.PUT_REQUEST);
    bsm.setPutRequest(prm);
    
    getReply(header.getTransactionId(), bsm);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:RemoteStore.java

示例6: addNode

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
/**
 * Add a new node to the cluster
 * @param node the {@link Node} to add
 * @throws SyncException if the node already exists
 */
private void addNode(Node node) throws SyncException {
    Short nodeId = node.getNodeId();
    if (allNodes.get(nodeId) != null) {
        throw new SyncException("Error adding node " + node +
                ": a node with that ID already exists");
    }
    allNodes.put(nodeId, node);

    Short domainId = node.getDomainId();
    List<Node> localDomain = localDomains.get(domainId);
    if (localDomain == null) {
        localDomains.put(domainId,
                         localDomain = new ArrayList<Node>());
    }
    localDomain.add(node);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:ClusterConfig.java

示例7: init

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
@Override
public void init(SyncManager syncManager, FloodlightModuleContext context) 
        throws SyncException {
    this.syncManager = syncManager;
    threadPool = context.getServiceImpl(IThreadPoolService.class);
    syncManager.registerPersistentStore(SYSTEM_NODE_STORE, Scope.GLOBAL);
    syncManager.registerPersistentStore(SYSTEM_UNSYNC_STORE, 
                                        Scope.UNSYNCHRONIZED);
    this.nodeStoreClient = 
            syncManager.getStoreClient(SYSTEM_NODE_STORE, 
                                       Short.class, Node.class);
    this.nodeStoreClient.addStoreListener(new ShortListener());
    this.unsyncStoreClient = 
            syncManager.getStoreClient(SYSTEM_UNSYNC_STORE, 
                                       String.class, String.class);
    this.unsyncStoreClient.addStoreListener(new StringListener());
    
    config = context.getConfigParams(syncManager);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:20,代码来源:SyncStoreCCProvider.java

示例8: handleError

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
@Override
protected void handleError(ErrorMessage error, Channel channel) {            
    ErrorType errType = ErrorType.GENERIC;
    for (ErrorType e : ErrorType.values()) {
        if (e.getValue() == error.getError().getErrorCode()) {
            errType = e;
            break;
        }
    }
    SyncException ex = 
            SyncException.newInstance(errType, 
                                      error.getError().getMessage(), 
                                      null);
    if (ChannelState.CONNECTED.equals(channelState) ||
        ChannelState.OPEN.equals(channelState) ||
        ErrorType.AUTH.equals(errType)) {
        syncManager.channelDisconnected(ex);
        channel.close();
    } else {
        SyncReply reply = new SyncReply(null, null, false, ex, 0);
        syncManager.dispatchReply(error.getHeader().getTransactionId(), 
                                  reply);
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:25,代码来源:RemoteSyncChannelHandler.java

示例9: getConfig

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
@Override
@LogMessageDoc(level="INFO",
    message="Cluster not yet configured; using fallback " + 
            "local configuration",
    explanation="No other nodes are known")
public ClusterConfig getConfig() throws SyncException {
    if (!warned) {
        logger.info("Cluster not yet configured; using fallback local " + 
                    "configuration");
        warned = true;
    }
    return new ClusterConfig(Collections.
                             singletonList(new Node("localhost",
                                                    syncPort,
                                                    Short.MAX_VALUE,
                                                    Short.MAX_VALUE)),
                                                    Short.MAX_VALUE,
                                                    "localhost",
                                                    authScheme,
                                                    keyStorePath,
                                                    keyStorePassword);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:23,代码来源:FallbackCCProvider.java

示例10: RemoteIterator

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
public RemoteIterator() {
    CursorRequestMessage crm = getCRM();
    crm.setStoreName(storeName);
    SyncMessage bsm = new SyncMessage(MessageType.CURSOR_REQUEST);
    bsm.setCursorRequest(crm);
    SyncReply reply;
    try {
        reply = getReply(crm.getHeader().getTransactionId(), 
                         bsm);
    } catch (SyncException e) {
        throw new SyncRuntimeException(e);
    }
    this.cursorId = reply.getIntValue();
    if (reply.getKeyedValues() != null)
        currentChunk = reply.getKeyedValues().iterator();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:17,代码来源:RemoteStore.java

示例11: getChunk

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
private Iterator<KeyedValues> getChunk() {
    CursorRequestMessage crm = getCRM();
    crm.setCursorId(cursorId);
    SyncMessage bsm = new SyncMessage(MessageType.CURSOR_REQUEST);
    bsm.setCursorRequest(crm);

    SyncReply reply;
    try {
        reply = getReply(crm.getHeader().getTransactionId(), 
                                      bsm);
    } catch (SyncException e) {
        throw new SyncRuntimeException(e);
    }
    if (reply.getKeyedValues() == null || 
        reply.getKeyedValues().size() == 0) return null;

    return reply.getKeyedValues().iterator();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:19,代码来源:RemoteStore.java

示例12: ensureConnected

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
protected void ensureConnected() {
    if (!ready) {
        for (int i = 0; i < 2; i++) {
            synchronized (this) {
                connectionGeneration += 1;
                if (connect(hostname, port))
                    return;
            }
            try {
                Thread.sleep(1000);
            } catch (Exception e) {}
        }
        if (channel == null) 
            throw new SyncRuntimeException(new SyncException("Failed to establish connection"));
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:17,代码来源:RemoteSyncManager.java

示例13: cleanupTask

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
@Override
public void cleanupTask() throws SyncException {
    Connection dbConnection = null;
    PreparedStatement stmt = null;
    try {
        dbConnection = getConnection();
        dbConnection.setAutoCommit(true);
        stmt = dbConnection.prepareStatement(getSql(SELECT_ALL));
        ResultSet rs = stmt.executeQuery();
        while (rs.next()) {
            List<Versioned<byte[]>> items = getVersionedList(rs);
            if (StoreUtils.canDelete(items, tombstoneDeletion)) {
                doClearTombstone(rs.getString("datakey"));
            }
        }                
    } catch (Exception e) {
        logger.error("Failed to delete key", e);
    } finally {
        cleanupSQL(dbConnection, stmt);
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:22,代码来源:JavaDBStorageEngine.java

示例14: get

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
@Override
public List<Versioned<byte[]>> get(ByteArray key) throws SyncException {
    StoreUtils.assertValidKey(key);
    Connection dbConnection = null;
    PreparedStatement stmt = null;
    try {
        dbConnection = getConnection();
        stmt = dbConnection.prepareStatement(getSql(SELECT_KEY));
        return doSelect(stmt, getKeyAsString(key));

    } catch (Exception e) {
        throw new PersistException("Could not retrieve key" +
                " from database",
                e);
    } finally {
        cleanupSQL(dbConnection, stmt);
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:19,代码来源:JavaDBStorageEngine.java

示例15: setupLocalNode

import org.sdnplatform.sync.error.SyncException; //导入依赖的package包/类
private Node setupLocalNode(Node localNode, Short localNodeId,
                            boolean firstNode) 
        throws SyncException {
    short nodeId = -1;
    short domainId = -1;
    if (localNode != null) {
        nodeId = localNode.getNodeId();
        domainId = localNode.getDomainId();
    } else if (localNodeId != null) {
        domainId = nodeId = localNodeId;
    } else if (firstNode) {
        domainId = nodeId = 
                (short)(new Random().nextInt(Short.MAX_VALUE));
    }
    Node n = getLocalNode(nodeId, domainId);
    return n;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:18,代码来源:SyncStoreCCProvider.java


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