private void loadNodeData() throws ConfigurationException { try { String address = GridLocatorUtil.getPublicAddress().getHostAddress(); Map<String, String> serviceProperties = new HashMap<>(); serviceProperties.put("connectorType", "console"); serviceProperties.put("protocol", "http"); serviceProperties.put("host", address); serviceProperties.put("port", "" + portNr); this.serviceInformation = new ServiceInformation("console", serviceProperties); } catch(ConfigurationException e) { throw new ConfigurationException("Unable to load public endpoint information", e); } }
@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(); }
public void addServiceInformation(ServiceInformation serviceInformation) { serviceInformationTypes.put(serviceInformation.getServiceType(), serviceInformation); }
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; } }
private void loadNodeData() throws ConfigurationException { try { String address = GridLocatorUtil.getPublicAddress().getHostAddress(); Map<String, String> serviceProperties = new HashMap<>(); serviceProperties.put("connectorType", "rest"); serviceProperties.put("protocol", "http"); serviceProperties.put("host", address); serviceProperties.put("port", "" + portNr); this.serviceInformation = new ServiceInformation("rest", serviceProperties); } catch(ConfigurationException e) { throw new ConfigurationException("Unable to load public endpoint information", e); } }
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 NodeInformation createNodeInformation(String hostname, boolean ssl, boolean verifyCert, int port) { Map<String, String> serviceDetails = new HashMap<>(); serviceDetails.put("connectorType", "rest"); String protocol = "http"; if(ssl) { protocol = "https"; } serviceDetails.put("verifyCert", Boolean.toString(verifyCert)); serviceDetails.put("protocol", protocol); serviceDetails.put("host", hostname); serviceDetails.put("port", "" + port); serviceDetails.put("clientid", clientId); NodeInformation nodeInformation = new NodeInformation("", ""); nodeInformation.addServiceInformation(new ServiceInformation("rest", serviceDetails)); return nodeInformation; } }