Search in sources :

Example 11 with ZkConnection

use of com.emc.storageos.coordinator.common.impl.ZkConnection in project coprhd-controller by CoprHD.

the class ProtocolSocketFactoryTest method setup.

@Before
public void setup() throws Exception {
    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);
    ks = KeyStoreUtil.getViPRKeystore(coordinatorClient);
    KeyCertificatePairGenerator gen = new KeyCertificatePairGenerator();
    gen.setKeyCertificateAlgorithmValuesHolder(new KeyCertificateAlgorithmValuesHolder(coordinatorClient));
    entry = gen.generateKeyCertificatePair();
    hostName = System.getenv(KeyCertificatePairGeneratorTest.LOCALHOST_IP);
    if (StringUtils.isBlank(hostName)) {
        hostName = "localhost";
    }
    webServer = new TestWebServer(entry);
    webServer.start();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) FileInputStream(java.io.FileInputStream) 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) Before(org.junit.Before)

Example 12 with ZkConnection

use of com.emc.storageos.coordinator.common.impl.ZkConnection in project coprhd-controller by CoprHD.

the class SSLSocketFactoryTest method setup.

@Before
public void setup() throws Exception {
    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);
    ks = KeyStoreUtil.getViPRKeystore(coordinatorClient);
    KeyCertificateAlgorithmValuesHolder values = new KeyCertificateAlgorithmValuesHolder(coordinatorClient);
    gen = new KeyCertificatePairGenerator();
    gen.setKeyCertificateAlgorithmValuesHolder(values);
    entry = gen.generateKeyCertificatePair();
    hostName = System.getenv(KeyCertificatePairGeneratorTest.LOCALHOST_IP);
    if (StringUtils.isBlank(hostName)) {
        hostName = "localhost";
    }
    webServer = new TestWebServer(entry);
    webServer.start();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) FileInputStream(java.io.FileInputStream) 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) Before(org.junit.Before)

Example 13 with ZkConnection

use of com.emc.storageos.coordinator.common.impl.ZkConnection in project coprhd-controller by CoprHD.

the class TrustManagerTest 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);
    loadStoreParam = new DistributedLoadKeyStoreParam();
    loadStoreParam.setCoordinator(coordinatorClient);
}
Also used : HashMap(java.util.HashMap) DistributedLoadKeyStoreParam(com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam) ArrayList(java.util.ArrayList) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Example 14 with ZkConnection

use of com.emc.storageos.coordinator.common.impl.ZkConnection in project coprhd-controller by CoprHD.

the class GeoSeedProviderImpl method initCoordinatorClient.

/**
 * Construct coordinator client from argument. Seed provider instance is created by cassandra
 * on demand. Not from spring context.
 *
 * @param args
 */
private void initCoordinatorClient(Map<String, String> args) throws IOException {
    // endpoints for coordinator in local site
    String coordinatorArg = args.get(COORDINATORS);
    if (coordinatorArg == null || coordinatorArg.trim().isEmpty()) {
        throw new IllegalArgumentException(COORDINATORS);
    }
    String[] coordinators = coordinatorArg.split(",", -1);
    List<URI> uri = new ArrayList<URI>(coordinators.length);
    for (String coord : coordinators) {
        if (!coord.trim().isEmpty()) {
            uri.add(URI.create(coord.trim()));
        }
    }
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    String siteIdFile = args.get(Constants.SITE_ID_FILE);
    connection.setSiteIdFile(siteIdFile);
    connection.build();
    CoordinatorClientImpl client = new CoordinatorClientImpl();
    client.setZkConnection(connection);
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/nodeaddrmap-var.xml");
    CoordinatorClientInetAddressMap inetAddressMap = (CoordinatorClientInetAddressMap) ctx.getBean("inetAddessLookupMap");
    if (inetAddressMap == null) {
        log.error("CoordinatorClientInetAddressMap is not initialized. Node address lookup will fail.");
    }
    // HARCODE FOR NOW
    client.setInetAddessLookupMap(inetAddressMap);
    client.start();
    coordinator = client;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ArrayList(java.util.ArrayList) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection)

Example 15 with ZkConnection

use of com.emc.storageos.coordinator.common.impl.ZkConnection in project coprhd-controller by CoprHD.

the class DbSvcRunner method getCoordinator.

/**
 * Get CoordinatorClient instance
 *
 * @return
 * @throws URISyntaxException
 * @throws IOException
 */
public CoordinatorClient getCoordinator() throws URISyntaxException, IOException {
    if (coordinator == null) {
        ZkConnection zkConn = new ZkConnection();
        List<URI> uris = new ArrayList<URI>();
        uris.add(new URI("coordinator://localhost:2181"));
        zkConn.setServer(uris);
        zkConn.setTimeoutMs(10000);
        zkConn.build();
        // Suppress Sonar violation of Lazy initialization of static fields should be synchronized
        // Junit test will be called in single thread by default, it's safe to ignore this violation
        // NOSONAR ("squid:S2444")
        coordinator = new CoordinatorClientImpl();
        coordinator.setZkConnection(zkConn);
        coordinator.setSysSvcName("syssvc");
        coordinator.setSysSvcVersion("1");
        coordinator.setNodeCount(1);
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("nodeaddrmap-var.xml");
        CoordinatorClientInetAddressMap inetAddressMap = (CoordinatorClientInetAddressMap) ctx.getBean("inetAddessLookupMap");
        if (inetAddressMap == null) {
            log.error("CoordinatorClientInetAddressMap is not initialized. Node address lookup will fail.");
        }
        Map<String, DualInetAddress> controlNodes = inetAddressMap.getControllerNodeIPLookupMap();
        // HARCODE FOR NOW
        coordinator.setInetAddessLookupMap(inetAddressMap);
        DbVersionInfo dbVersionInfo = new DbVersionInfo();
        dbVersionInfo.setSchemaVersion(SVC_VERSION);
        coordinator.setDbVersionInfo(dbVersionInfo);
        coordinator.start();
    }
    return coordinator;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ArrayList(java.util.ArrayList) 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)

Aggregations

ZkConnection (com.emc.storageos.coordinator.common.impl.ZkConnection)20 URI (java.net.URI)12 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)9 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)8 ArrayList (java.util.ArrayList)8 CoordinatorClientImpl (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)6 FileInputStream (java.io.FileInputStream)6 Before (org.junit.Before)6 Properties (java.util.Properties)5 CuratorFramework (org.apache.curator.framework.CuratorFramework)5 Timing (org.apache.curator.test.Timing)5 Test (org.junit.Test)5 KeyCertificateAlgorithmValuesHolder (com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder)4 HashMap (java.util.HashMap)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 KeyCertificatePairGenerator (com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator)3 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)2 DistributedLoadKeyStoreParam (com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 StubCoordinatorClientImpl (com.emc.sa.model.mock.StubCoordinatorClientImpl)1