/** * resolve the host ip address * * @param host the host which it's address is about to be resolved * @return if succeeded, string representing the host ip in IPv4 format, null otherwise */ public static String getHostByIp(VDS host) { try { final InetAddress address = InetAddress.getByName(host.getHostName()); return address.getHostAddress().trim(); } catch (UnknownHostException ex) { final String msg = "Failed to resolve host ip by name '{}'"; log.warn(msg, " Details: '{}' ", host.getHostName(), ex.getCause()); log.debug(msg, host.getHostName(), ex); return null; } }
private GlusterVolumeEntity getNewVolume() { GlusterVolumeEntity volume = new GlusterVolumeEntity(); volume.setName(NEW_VOL_NAME); volume.setClusterId(CLUSTER_ID); volume.setId(NEW_VOL_ID); volume.setVolumeType(GlusterVolumeType.DISTRIBUTE); volume.addTransportType(TransportType.TCP); volume.setReplicaCount(0); volume.setStripeCount(0); volume.setStatus(GlusterStatus.UP); volume.setOption("auth.allow", "*"); volume.addAccessProtocol(AccessProtocol.GLUSTER); volume.addAccessProtocol(AccessProtocol.NFS); GlusterBrickEntity brick = new GlusterBrickEntity(); brick.setVolumeId(NEW_VOL_ID); brick.setServerId(existingServer1.getId()); brick.setServerName(existingServer1.getHostName()); brick.setBrickDirectory("/export/testvol1"); brick.setStatus(GlusterStatus.UP); brick.setBrickOrder(0); volume.addBrick(brick); return volume; }
private GlusterBrickEntity createBrick(Guid existingVolDistId, VDS server, String brickDir) { GlusterBrickEntity brick = new GlusterBrickEntity(); brick.setVolumeId(existingVolDistId); brick.setServerId(server.getId()); brick.setServerName(server.getHostName()); brick.setBrickDirectory(brickDir); brick.setStatus(GlusterStatus.UP); return brick; }
/** @return A unique host name representation */ public static String getUniqueHostName(VDS host) { return host.getHostName() + "-" + DigestUtils.md5Hex(host.getId().toByteArray()).substring(0, 6); }