@Override public String getCachingKey(NodeInformation nodeInformation, Class<? extends RemoteConnector> operationInterface) { Map<String, String> props = nodeInformation.getServiceInformation("rest").getNodeProperties(); return nodeInformation.getInstanceId() + props.get(RemoteRestConnector.CONNECTION_HOST_PROPERTY) + props.get(RemoteRestConnector.CONNECTION_PORT_PROPERTY) + operationInterface.getName(); }
private void loadHostAddress(NodeInformation nodeInformation) throws ConfigurationException { Map<String, ?> remoteProperties = nodeInformation.getServiceInformation("rest").getNodeProperties(); if(remoteProperties.containsKey(CONNECTION_HOST_PROPERTY) && remoteProperties.containsKey(CONNECTION_PORT_PROPERTY) && remoteProperties.containsKey(CONNECTION_PROTOCOL_PROPERTY)) { String host = (String)remoteProperties.get(CONNECTION_HOST_PROPERTY); String port = (String)remoteProperties.get(CONNECTION_PORT_PROPERTY); String protocol = (String) remoteProperties.get(CONNECTION_PROTOCOL_PROPERTY); if(remoteProperties.containsKey("verifyCert") && remoteProperties.get("verifyCert").equals("false")) { disableCertificationValidation(); } if(protocol.equals("http") || protocol.equals("https")) { try { int portNumber = Integer.parseInt(port); this.baseUrl = protocol + "://" + host + ":" + portNumber + "/"; LOG.debug("Loaded rest connector with baseUrl: {}", baseUrl); } catch(NumberFormatException e) { throw new ConfigurationException("Invalid Rest client port number: " + port); } } else { throw new ConfigurationException("Unsupported Rest client protocol: " + protocol); } } else { throw new ConfigurationException("Unable to load remote connection properties to establish rest client connection"); } }
public static <T extends RemoteConnector> T createConnector(NodeInformation nodeInformation, Class<T> operationInterface) throws RemoteException { if(nodeInformation.getServiceInformationList().size() > 0) { String serviceType; if(nodeInformation.getServiceInformation(instance.preferredType) != null) { serviceType = instance.preferredType; } else { serviceType = nodeInformation.getServiceInformationList().get(0).getServiceType(); } Map<String, ?> properties = nodeInformation.getServiceInformation(serviceType).getNodeProperties(); if(serviceType != null && properties != null) { return instance.loadConnector(nodeInformation, serviceType, operationInterface); } } throw new RemoteException("Remote grid nodeInformation connection information contains not enough connection information: " + nodeInformation.toString()); }
public static Node mapTo(NodeInformation nodeInformation) { if(nodeInformation != null) { Node mappedNode = new Node(); mappedNode.setGridId(nodeInformation.getGridId()); mappedNode.setInstanceId(nodeInformation.getInstanceId()); List<NodeServiceInformation> nodeServices = new ArrayList<>(); for(ServiceInformation serviceInformation : nodeInformation.getServiceInformationList()) { NodeServiceInformation nodeService = new NodeServiceInformation(); nodeService.setProperties(serviceInformation.getNodeProperties()); nodeService.setServiceType(serviceInformation.getServiceType()); nodeServices.add(nodeService); } mappedNode.setServices(nodeServices); return mappedNode; } else { return null; } }