Search in sources :

Example 1 with DualInetAddress

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

the class DbManager method removeNode.

@Override
public void removeNode(String nodeId) {
    Map<String, DualInetAddress> idMap = this.coordinator.getInetAddessLookupMap().getControllerNodeIPLookupMap();
    DualInetAddress dualAddr = idMap.get(nodeId);
    if (dualAddr == null) {
        String errMsg = String.format("Cannot find node with name %s", nodeId);
        log.error(errMsg);
        throw new IllegalArgumentException(errMsg);
    }
    Map<String, String> hostIdMap = StorageService.instance.getHostIdMap();
    Map<String, String> ipGuidMap = new HashMap<String, String>();
    for (Map.Entry<String, String> entry : hostIdMap.entrySet()) {
        ipGuidMap.put(normalizeInetAddress(entry.getKey()), entry.getValue());
    }
    String nodeGuid = dualAddr.hasInet4() ? ipGuidMap.get(dualAddr.getInet4()) : null;
    if (nodeGuid == null) {
        nodeGuid = dualAddr.hasInet6() ? ipGuidMap.get(dualAddr.getInet6()) : null;
    }
    if (nodeGuid == null) {
        String errMsg = String.format("Cannot find Cassandra node with IP address %s", dualAddr.toString());
        log.error(errMsg);
        throw new IllegalArgumentException(errMsg);
    }
    log.info("Removing Cassandra node {} on vipr node {}", nodeGuid, nodeId);
    ensureRemoveNode(nodeGuid);
}
Also used : HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Example 2 with DualInetAddress

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

the class TestDBClientUtils method newDBClient.

public static DbClientImpl newDBClient() throws Exception {
    ZkConnection zkConnection = new ZkConnection();
    zkConnection.setServer(Lists.newArrayList(new URI("coordinator://localhost:2181")));
    zkConnection.build();
    DualInetAddress dualInetAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    Map<String, DualInetAddress> addresses = Maps.newHashMap();
    addresses.put("localhost", dualInetAddress);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    map.setDualInetAddress(dualInetAddress);
    map.setControllerNodeIPLookupMap(addresses);
    CoordinatorClientImpl coordinatorClient = new CoordinatorClientImpl();
    coordinatorClient.setZkConnection(zkConnection);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    DbClientContext localContext = new DbClientContext();
    localContext.setKeyspaceName("StorageOS");
    localContext.setClusterName("StorageOs");
    DbClientContext geoContext = new DbClientContext();
    geoContext.setKeyspaceName("GeoStorageOs");
    geoContext.setClusterName("GeoStorageOs");
    DbVersionInfo versionInfo = new DbVersionInfo();
    versionInfo.setSchemaVersion("2.0");
    DbClientImpl client = new DbClientImpl();
    client.setDbVersionInfo(versionInfo);
    client.setLocalContext(localContext);
    client.setGeoContext(geoContext);
    client.setCoordinatorClient(coordinatorClient);
    client.setLocalContext(new DbClientContext());
    client.start();
    VdcUtil.setDbClient(client);
    return client;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) DbClientContext(com.emc.storageos.db.client.impl.DbClientContext) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo)

Example 3 with DualInetAddress

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

the class DualInetAddressTest method testEquals.

@Test
public void testEquals() {
    System.out.println("*** testEqual: Start");
    try {
        DualInetAddress cn = DualInetAddress.fromAddress(null);
        DualInetAddress sn = DualInetAddress.fromAddress(null);
        DualInetAddress c4 = DualInetAddress.fromAddresses(c_ip4, null);
        DualInetAddress c6 = DualInetAddress.fromAddresses(null, c_ip6);
        DualInetAddress cm = DualInetAddress.fromAddresses(c_ip4, c_ip6);
        DualInetAddress s4 = DualInetAddress.fromAddresses(c_ip4, null);
        DualInetAddress s6 = DualInetAddress.fromAddresses(null, c_ip6);
        DualInetAddress sm = DualInetAddress.fromAddresses(c_ip4, c_ip6);
        // Checks for empty ip strings
        DualInetAddress blank_v4 = DualInetAddress.fromAddresses("", c_ip6);
        DualInetAddress blank_v6 = DualInetAddress.fromAddresses(c_ip4, "");
        DualInetAddress blank_all = DualInetAddress.fromAddresses("", "");
        Assert.assertTrue(blank_v4.equals(s6));
        Assert.assertTrue(blank_v6.equals(s4));
        Assert.assertTrue(blank_all.equals(cn));
        // Test strings, nulls for equals
        Assert.assertFalse(cn == null);
        Assert.assertTrue(cn.equals(cn));
        Assert.assertTrue(sn.equals(sn));
        Assert.assertTrue(sn.equals(cn));
        Assert.assertTrue(cn.equals(sn));
        Assert.assertTrue(c4.equals(c4));
        Assert.assertTrue(s4.equals(s4));
        Assert.assertTrue(s4.equals(c4));
        Assert.assertTrue(c4.equals(s4));
        Assert.assertTrue(c6.equals(c6));
        Assert.assertTrue(s6.equals(s6));
        Assert.assertTrue(s6.equals(c6));
        Assert.assertTrue(c6.equals(s6));
        Assert.assertTrue(cm.equals(cm));
        Assert.assertTrue(sm.equals(sm));
        Assert.assertTrue(sm.equals(cm));
        Assert.assertTrue(cm.equals(sm));
        Assert.assertFalse(cn.equals(c4));
        Assert.assertFalse(cn.equals(cm));
        Assert.assertFalse(cn.equals(c6));
        Assert.assertFalse(c4.equals(cn));
        Assert.assertFalse(c4.equals(cm));
        Assert.assertFalse(c4.equals(c6));
        Assert.assertFalse(c6.equals(cn));
        Assert.assertFalse(c6.equals(cm));
        Assert.assertFalse(c6.equals(c4));
        Assert.assertFalse(cm.equals(cn));
        Assert.assertFalse(cm.equals(c4));
        Assert.assertFalse(cm.equals(c6));
        Assert.assertTrue(sn.hashCode() == cn.hashCode());
        Assert.assertTrue(cn.hashCode() == sn.hashCode());
        Assert.assertTrue(s4.hashCode() == c4.hashCode());
        Assert.assertTrue(c4.hashCode() == s4.hashCode());
        Assert.assertTrue(s6.hashCode() == c6.hashCode());
        Assert.assertTrue(c6.hashCode() == s6.hashCode());
        Assert.assertTrue(sm.hashCode() == cm.hashCode());
        Assert.assertTrue(cm.hashCode() == sm.hashCode());
        Assert.assertFalse(cn.hashCode() == c4.hashCode());
        Assert.assertFalse(cn.hashCode() == cm.hashCode());
        Assert.assertFalse(cn.hashCode() == c6.hashCode());
        Assert.assertFalse(c4.hashCode() == cn.hashCode());
        Assert.assertFalse(c4.hashCode() == cm.hashCode());
        Assert.assertFalse(c4.hashCode() == c6.hashCode());
        Assert.assertFalse(c6.hashCode() == cn.hashCode());
        Assert.assertFalse(c6.hashCode() == cm.hashCode());
        Assert.assertFalse(c6.hashCode() == c4.hashCode());
        Assert.assertFalse(cm.hashCode() == cn.hashCode());
        Assert.assertFalse(cm.hashCode() == c4.hashCode());
        Assert.assertFalse(cm.hashCode() == c6.hashCode());
    } catch (UnknownHostException e) {
        Assert.assertTrue(false);
    }
    System.out.println("*** testEqual: Start");
}
Also used : UnknownHostException(java.net.UnknownHostException) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) Test(org.junit.Test)

Example 4 with DualInetAddress

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

the class KeyCertificatePairGeneratorTest method setup.

@Before
public void setup() throws IOException, URISyntaxException {
    ApplicationContextUtil.initContext(System.getProperty("buildType"), ApplicationContextUtil.SECURITY_CONTEXTS);
    List<URI> uri = new ArrayList<URI>();
    uri.add(URI.create(coordinatorServer));
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    connection.build();
    coordinatorClient.setZkConnection(connection);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    DualInetAddress localAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    map.setDualInetAddress(localAddress);
    Map<String, DualInetAddress> controllerNodeIPLookupMap = new HashMap<String, DualInetAddress>();
    controllerNodeIPLookupMap.put("localhost", localAddress);
    map.setControllerNodeIPLookupMap(controllerNodeIPLookupMap);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    FileInputStream is = new FileInputStream(defaultOvfPropsLocation);
    Properties defaultProp = new Properties();
    defaultProp.load(is);
    is.close();
    is = new FileInputStream(ovfPropsLocation);
    Properties ovfProps = new Properties();
    ovfProps.load(is);
    is.close();
    CoordinatorClientImpl.setDefaultProperties(defaultProp);
    CoordinatorClientImpl.setOvfProperties(ovfProps);
    defaultValues = new KeyCertificateAlgorithmValuesHolder(coordinatorClient);
    String envVar = System.getenv(LOCALHOST_IP);
    if (StringUtils.isNotBlank(envVar)) {
        localhostIP = envVar;
    }
    InetAddress localhost = InetAddress.getByName(localhostIP);
    localhostName = localhost.getCanonicalHostName();
}
Also used : URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) FileInputStream(java.io.FileInputStream) KeyCertificateAlgorithmValuesHolder(com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) InetAddress(java.net.InetAddress) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) Before(org.junit.Before)

Example 5 with DualInetAddress

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

the class KeystoreTest method setup.

@Before
public void setup() throws URISyntaxException, IOException {
    ApplicationContextUtil.initContext(System.getProperty("buildType"), ApplicationContextUtil.SECURITY_CONTEXTS);
    List<URI> uri = new ArrayList<URI>();
    uri.add(URI.create(coordinatorServer));
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    connection.build();
    coordinatorClient.setZkConnection(connection);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    DualInetAddress localAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    map.setDualInetAddress(localAddress);
    Map<String, DualInetAddress> controllerNodeIPLookupMap = new HashMap<String, DualInetAddress>();
    controllerNodeIPLookupMap.put("localhost", localAddress);
    map.setControllerNodeIPLookupMap(controllerNodeIPLookupMap);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    FileInputStream is = new FileInputStream(defaultOvfPropsLocation);
    Properties defaultProp = new Properties();
    defaultProp.load(is);
    is.close();
    is = new FileInputStream(ovfPropsLocation);
    Properties ovfProps = new Properties();
    ovfProps.load(is);
    is.close();
    CoordinatorClientImpl.setDefaultProperties(defaultProp);
    CoordinatorClientImpl.setOvfProperties(ovfProps);
    loadStoreParam = new DistributedLoadKeyStoreParam();
    loadStoreParam.setCoordinator(coordinatorClient);
    invalidLoadStoreParam = new LoadStoreParameter() {

        @Override
        public ProtectionParameter getProtectionParameter() {
            return null;
        }
    };
    gen = new KeyCertificatePairGenerator();
    KeyCertificateAlgorithmValuesHolder values = new KeyCertificateAlgorithmValuesHolder(coordinatorClient);
    gen.setKeyCertificateAlgorithmValuesHolder(values);
}
Also used : HashMap(java.util.HashMap) DistributedLoadKeyStoreParam(com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam) ArrayList(java.util.ArrayList) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) FileInputStream(java.io.FileInputStream) LoadStoreParameter(java.security.KeyStore.LoadStoreParameter) KeyCertificateAlgorithmValuesHolder(com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder) KeyCertificatePairGenerator(com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) ProtectionParameter(java.security.KeyStore.ProtectionParameter) Before(org.junit.Before)

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