Search in sources :

Example 11 with DualInetAddress

use of com.emc.storageos.coordinator.client.service.impl.DualInetAddress in project coprhd-controller by CoprHD.

the class BackupOps method getLocalHost.

private String getLocalHost() {
    Preconditions.checkNotNull(coordinatorClient, "Please initialize coordinator client before any operations");
    DualInetAddress inetAddress = coordinatorClient.getInetAddessLookupMap().getDualInetAddress();
    return inetAddress.hasInet4() ? inetAddress.getInet4() : inetAddress.getInet6();
}
Also used : DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Example 12 with DualInetAddress

use of com.emc.storageos.coordinator.client.service.impl.DualInetAddress in project coprhd-controller by CoprHD.

the class RestoreManager method checkHostsIp.

private boolean checkHostsIp(String[] backupHostArray) throws IOException {
    DualInetAddress currentHostAddress = DualInetAddress.fromAddresses(ipAddress4, ipAddress6);
    log.info("Current Host Ip: {}", currentHostAddress.toString());
    boolean inHostArray = false;
    for (String backupHost : backupHostArray) {
        DualInetAddress backupHostAddress;
        if (backupHost.contains(BackupConstants.HOSTS_IP_DELIMITER)) {
            String[] ips = backupHost.trim().split(BackupConstants.HOSTS_IP_DELIMITER);
            backupHostAddress = DualInetAddress.fromAddresses(ips[0], ips[1]);
        } else {
            backupHostAddress = DualInetAddress.fromAddress(backupHost.trim());
        }
        if (currentHostAddress.equals(backupHostAddress)) {
            inHostArray = true;
            break;
        }
    }
    return inHostArray;
}
Also used : DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Example 13 with DualInetAddress

use of com.emc.storageos.coordinator.client.service.impl.DualInetAddress in project coprhd-controller by CoprHD.

the class DbManager method getNodeStates.

@Override
public Map<String, Boolean> getNodeStates() {
    Map<String, Boolean> ipStateMap = new TreeMap<>();
    while (true) {
        List<String> upNodes = StorageService.instance.getLiveNodes();
        List<String> downNodes = StorageService.instance.getUnreachableNodes();
        List<String> upNodes2 = StorageService.instance.getLiveNodes();
        if (new HashSet<>(upNodes).equals(new HashSet<>(upNodes2))) {
            addAll(ipStateMap, upNodes, true);
            addAll(ipStateMap, downNodes, false);
            break;
        }
    }
    Map<String, DualInetAddress> idIpMap = this.coordinator.getInetAddessLookupMap().getControllerNodeIPLookupMap();
    Map<String, Boolean> idStateMap = new TreeMap<>();
    for (Map.Entry<String, DualInetAddress> entry : idIpMap.entrySet()) {
        DualInetAddress dualAddr = entry.getValue();
        Boolean state = dualAddr.hasInet4() ? ipStateMap.get(dualAddr.getInet4()) : null;
        if (state == null) {
            state = dualAddr.hasInet6() ? ipStateMap.get(dualAddr.getInet6()) : null;
        }
        if (state != null) {
            idStateMap.put(entry.getKey(), state);
        }
    }
    return idStateMap;
}
Also used : TreeMap(java.util.TreeMap) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Example 14 with DualInetAddress

use of com.emc.storageos.coordinator.client.service.impl.DualInetAddress in project coprhd-controller by CoprHD.

the class DbServiceTestBase method startDb.

/**
 * Start embedded DB
 */
protected void startDb(String schemaVersion, String extraModelsPkg) throws Exception {
    List<String> packages = new ArrayList<String>();
    packages.add("com.emc.storageos.db.client.model");
    if (extraModelsPkg != null) {
        packages.add(extraModelsPkg);
    }
    String[] pkgsArray = packages.toArray(new String[packages.size()]);
    ServiceImpl service = new ServiceImpl();
    service.setName("dbsvc");
    service.setVersion(schemaVersion);
    service.setEndpoint(URI.create("thrift://localhost:9160"));
    service.setId("db-standalone");
    DataObjectScanner scanner = new DataObjectScanner();
    scanner.setPackages(pkgsArray);
    scanner.init();
    dbVersionInfo = new DbVersionInfo();
    dbVersionInfo.setSchemaVersion(schemaVersion);
    coordinator.setDbVersionInfo(dbVersionInfo);
    DbServiceStatusChecker statusChecker = new DbServiceStatusChecker();
    statusChecker.setCoordinator(coordinator);
    statusChecker.setClusterNodeCount(1);
    statusChecker.setDbVersionInfo(dbVersionInfo);
    statusChecker.setServiceName(service.getName());
    CoordinatorClientInetAddressMap coordinatorMap = new CoordinatorClientInetAddressMap();
    coordinatorMap.setNodeId("localhost");
    coordinatorMap.setDualInetAddress(DualInetAddress.fromAddress("127.0.0.1"));
    Map<String, DualInetAddress> addressLookupMap = new HashMap<String, DualInetAddress>();
    addressLookupMap.put(coordinatorMap.getNodeId(), coordinatorMap.getDualInetAddress());
    coordinatorMap.setControllerNodeIPLookupMap(addressLookupMap);
    coordinatorMap.setCoordinatorClient(coordinator);
    coordinator.setInetAddessLookupMap(coordinatorMap);
    SchemaUtil util = new SchemaUtil();
    util.setKeyspaceName("Test");
    util.setClusterName("Test");
    util.setDataObjectScanner(scanner);
    util.setService(service);
    util.setStatusChecker(statusChecker);
    util.setCoordinator(coordinator);
    util.setVdcShortId("vdc1");
    util.setClientContext(createLocalContext());
    List<String> vdcHosts = new ArrayList();
    vdcHosts.add("127.0.0.1");
    util.setVdcNodeList(vdcHosts);
    util.setDbCommonInfo(new java.util.Properties());
    dbsvc = new InternalDbService();
    dbsvc.setConfig("db-test.yaml");
    dbsvc.setSchemaUtil(util);
    dbsvc.setCoordinator(coordinator);
    dbsvc.setStatusChecker(statusChecker);
    dbsvc.setService(service);
    dbsvc.setDbDir(".");
    JmxServerWrapper jmx = new JmxServerWrapper();
    jmx.setEnabled(false);
    dbsvc.setJmxServerWrapper(jmx);
    dbClient = getDbClientBase();
    dbsvc.setDbClient(dbClient);
    PasswordUtils passwordUtils = new PasswordUtils();
    passwordUtils.setCoordinator(coordinator);
    EncryptionProviderImpl provider = new EncryptionProviderImpl();
    provider.setCoordinator(coordinator);
    provider.start();
    passwordUtils.setEncryptionProvider(provider);
    passwordUtils.setDbClient(dbClient);
    util.setPasswordUtils(passwordUtils);
    StubBeaconImpl beacon = new StubBeaconImpl(service);
    dbsvc.setBeacon(beacon);
    MigrationHandlerImpl handler = new MigrationHandlerImpl();
    handler.setPackages(pkgsArray);
    handler.setService(service);
    handler.setStatusChecker(statusChecker);
    handler.setCoordinator(coordinator);
    handler.setDbClient(dbClient);
    handler.setSchemaUtil(util);
    dbsvc.setMigrationHandler(handler);
    dbsvc.setDisableScheduledDbRepair(true);
    dbsvc.start();
}
Also used : DataObjectScanner(com.emc.storageos.db.common.DataObjectScanner) InternalDbService(com.emc.storageos.db.server.upgrade.util.InternalDbService) HashMap(java.util.HashMap) ServiceImpl(com.emc.storageos.coordinator.common.impl.ServiceImpl) MigrationHandlerImpl(com.emc.storageos.db.server.impl.MigrationHandlerImpl) ArrayList(java.util.ArrayList) DbServiceStatusChecker(com.emc.storageos.db.common.DbServiceStatusChecker) PasswordUtils(com.emc.storageos.security.password.PasswordUtils) EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo) SchemaUtil(com.emc.storageos.db.server.impl.SchemaUtil) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) StubBeaconImpl(com.emc.storageos.db.server.util.StubBeaconImpl) JmxServerWrapper(com.emc.storageos.services.util.JmxServerWrapper) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Example 15 with DualInetAddress

use of com.emc.storageos.coordinator.client.service.impl.DualInetAddress in project coprhd-controller by CoprHD.

the class HealthMonitorService method getHealth.

/**
 * Gets health of node and its services.
 * <p/>
 * Node health status: Good - when node is reachable and all its services are GOOD Unavailable - when node is not reachable Degraded -
 * when node is reachable and any of its service is Unavailable/Degraded Node/syssvc Unavailable - when node is down or syssvc is not
 * Unavailable on the node
 * <p/>
 * Service health status: Good - when a service is up and running Unavailable - when a service is not running but is registered in
 * coordinator Restarted - when service is restarting
 *
 * @brief Show service health of all virtual machines
 * @param nodeIds node ids for which health stats are collected.
 * @param nodeNames node names for which health stats are collected.
 * @prereq none
 * @return Health response.
 */
@GET
@Path("/health")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.SECURITY_ADMIN })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HealthRestRep getHealth(@QueryParam("node_id") List<String> nodeIds, @QueryParam("node_name") List<String> nodeNames) {
    HealthRestRep healthRestRep = new HealthRestRep();
    List<NodeHealth> nodehealthList = healthRestRep.getNodeHealthList();
    nodeIds = _coordinatorClientExt.combineNodeNamesWithNodeIds(nodeNames, nodeIds);
    // Collecting data from all nodes
    List<NodeInfo> nodeInfoList = ClusterNodesUtil.getClusterNodeInfo(nodeIds);
    Map<String, NodeHealth> nodesData = NodeDataCollector.getDataFromNodes(nodeInfoList, INTERNAL_NODE_HEALTH_URI, Action.GET, null, NodeHealth.class, null);
    nodehealthList.addAll(nodesData.values());
    String thisNodeId = _coordinatorClientExt.getMyNodeId();
    if (thisNodeId.equals("standalone")) {
        return healthRestRep;
    }
    Map<String, DualInetAddress> ipLookupTable = _coordinatorClientExt.getCoordinatorClient().getInetAddessLookupMap().getControllerNodeIPLookupMap();
    // get all nodes if the input param is empty
    if (nodeIds == null || nodeIds.isEmpty()) {
        int clusterNodeCount = _coordinatorClientExt.getNodeCount();
        nodeIds = new ArrayList<>();
        for (int i = 1; i <= clusterNodeCount; i++) {
            String nodeId = "vipr" + i;
            nodeIds.add(nodeId);
        }
    }
    // Adding health for nodes that are not returned
    for (String nodeId : nodeIds) {
        DualInetAddress ip = ipLookupTable.get(nodeId);
        if (!nodesData.containsKey(nodeId)) {
            String nodeName = _coordinatorClientExt.getPropertyInfo().getProperty("node_" + nodeId.replace("vipr", "") + "_name");
            nodehealthList.add(new NodeHealth(nodeId, nodeName, ip.toString(), Status.NODE_OR_SYSSVC_UNAVAILABLE.toString()));
        }
    }
    return healthRestRep;
}
Also used : NodeInfo(com.emc.storageos.systemservices.impl.resource.util.NodeInfo) HealthRestRep(com.emc.vipr.model.sys.healthmonitor.HealthRestRep) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) NodeHealth(com.emc.vipr.model.sys.healthmonitor.NodeHealth) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)26 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)13 HashMap (java.util.HashMap)9 ZkConnection (com.emc.storageos.coordinator.common.impl.ZkConnection)8 URI (java.net.URI)8 FileInputStream (java.io.FileInputStream)6 UnknownHostException (java.net.UnknownHostException)6 ArrayList (java.util.ArrayList)6 Properties (java.util.Properties)5 Before (org.junit.Before)5 CoordinatorClientImpl (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)4 KeyCertificateAlgorithmValuesHolder (com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder)4 Test (org.junit.Test)4 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)3 KeyCertificatePairGenerator (com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator)3 DistributedLoadKeyStoreParam (com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 Ignore (org.junit.Ignore)2 SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)1