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);
}
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;
}
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");
}
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();
}
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);
}
Aggregations