Package org.sdnplatform.sync.error

Examples of org.sdnplatform.sync.error.SyncException


        logger.warn("[{}->{}] {}",
                    new Object[]{getLocalNodeIdString(),
                                 getRemoteNodeIdString(),
                                 message});
        channel.write(getError(transactionId,
                               new SyncException(message), type));
    }
View Full Code Here


                try {
                    Thread.sleep(1000);
                } catch (Exception e) {}
            }
            if (channel == null)
                throw new SyncRuntimeException(new SyncException("Failed to establish connection"));
        }
    }
View Full Code Here

            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) ||
View Full Code Here

                }
                newclock = newclock.incremented(syncManager.getLocalNodeId(),
                                                System.currentTimeMillis());
                value = Versioned.value(rvalue, newclock);
            } else {
                throw new SyncException("No value specified for put");
            }

            store.put(key, value);

            PutResponseMessage m = new PutResponseMessage();
View Full Code Here

                c = syncManager.getCursor(request.getCursorId());
            } else {
                c = syncManager.newCursor(request.getStoreName());
            }
            if (c == null) {
                throw new SyncException("Unrecognized cursor");
            }

            CursorResponseMessage m = new CursorResponseMessage();
            AsyncMessageHeader header = new AsyncMessageHeader();
            header.setTransactionId(request.getHeader().getTransactionId());
View Full Code Here

     * @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();
View Full Code Here

        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;
View Full Code Here

            try {
                is = new FileInputStream(BOOT_CONFIG);
                bootConfig.load(is);
                thisControllerID = bootConfig.getProperty("controller-id");
            } catch (Exception e) {
                throw new SyncException("No controller ID configured and " +
                                        "could not read " + BOOT_CONFIG);
            } finally {
                if (is != null) try {
                    is.close();
                } catch (IOException e) {
                    throw new SyncException(e);
                }
            }
        }
        if (thisControllerID == null) {
            throw new SyncException("No controller ID configured");
        }
        logger.debug("Using controller ID: {}", thisControllerID);

        List<Node> nodes = new ArrayList<Node>();
        short thisNodeId = -1;

        String[] cols = {CONTROLLER_ID,
                         CONTROLLER_SYNC_ID,
                         CONTROLLER_SYNC_DOMAIN_ID,
                         CONTROLLER_SYNC_PORT};
        IResultSet res = null;
        try {
            res = storageSource.executeQuery(CONTROLLER_TABLE_NAME,
                                             cols, null, null);
            while (res.next()) {
                String controllerId = res.getString(CONTROLLER_ID);
                if (!res.containsColumn(CONTROLLER_SYNC_ID) ||
                    !res.containsColumn(CONTROLLER_SYNC_DOMAIN_ID) ||
                    !res.containsColumn(CONTROLLER_SYNC_PORT)) {
                    logger.debug("No sync data found for {}", controllerId);
                    continue;
                }

                short nodeId = res.getShort(CONTROLLER_SYNC_ID);
                short domainId = res.getShort(CONTROLLER_SYNC_DOMAIN_ID);
                int port = res.getInt(CONTROLLER_SYNC_PORT);
                String syncIp = getNodeIP(controllerId);
                if (syncIp == null) {
                    logger.debug("No sync IP found for {}", controllerId);
                    continue;
                }
                Node node = new Node(syncIp, port, nodeId, domainId);
                nodes.add(node);

                if (thisControllerID.equals(controllerId))
                    thisNodeId = nodeId;
            }
        } finally {
            if (res != null) res.close();
        }

        if (nodes.size() == 0)
            throw new SyncException("No valid nodes found");
        if (thisNodeId < 0)
            throw new SyncException("Could not find a node for the local node");

        return new ClusterConfig(nodes, thisNodeId, authScheme,
                                 keyStorePath, keyStorePassword);
    }
View Full Code Here

    private Map<String, String> config;

    @Override
    public ClusterConfig getConfig() throws SyncException {
        if (!config.containsKey("nodes") || !config.containsKey("thisNode"))
            throw new SyncException("Configuration properties nodes or " +
                    "thisNode not set");

        String keyStorePath = config.get("keyStorePath");
        String keyStorePassword = config.get("keyStorePassword");
        AuthScheme authScheme = AuthScheme.NO_AUTH;
        try {
            authScheme = AuthScheme.valueOf(config.get("authScheme"));
        } catch (Exception e) {}
       
        Short thisNodeId;
        try {
            thisNodeId = Short.parseShort(config.get("thisNode"));
        } catch (NumberFormatException e) {
            throw new SyncException("Failed to parse thisNode " +
                    "node ID: " + config.get("thisNode"), e);
        }
        try {
            ObjectMapper mapper = new ObjectMapper();
            List<Node> nodes =
                    mapper.readValue(config.get("nodes"),
                                     new TypeReference<List<Node>>() { });
            return new ClusterConfig(nodes, thisNodeId,
                                     authScheme,
                                     keyStorePath,
                                     keyStorePassword);
        } catch (Exception e) {
            throw new SyncException("Could not update " +
                    "configuration", e);
        }
    }   
View Full Code Here

        Short localNodeId = getLocalNodeId();
        if (localNodeId == null) {
            String seedStr =
                    unsyncStoreClient.getValue(SyncStoreCCProvider.SEEDS);
            if (seedStr == null) {
                throw new SyncException("No local node ID and no seeds");
            }
            bootstrapTask.reschedule(0, TimeUnit.SECONDS);
            throw new SyncException("Local node ID not yet configured");
        }
       
        IClosableIterator<Entry<Short, Versioned<Node>>> iter =
                nodeStoreClient.entries();
        List<Node> nodes = new ArrayList<Node>();
View Full Code Here

TOP

Related Classes of org.sdnplatform.sync.error.SyncException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.