/** GemStoneAddition - find the lead member in this view */ public Address getLeadMember() { for (int i=0; i<members.size(); i++) { Address mbr = (Address)members.get(i); if (((IpAddress)mbr).getVmKind() == 10) { return mbr; } } return null; }
/** * return an InternalDistributedMember representing the given jgroups address * @param sender * @param createIfAbsent * @return the IDM for the given jgroups address */ public InternalDistributedMember getMemberFromIpAddress(IpAddress sender, boolean createIfAbsent) { synchronized(latestViewLock) { // logger.fine("DEBUG: getting member for ipAddr " + sender); InternalDistributedMember mbr = ipAddrToMemberMap.get(sender); if (mbr == null) { JGroupMember jgm = new JGroupMember(sender); mbr = new InternalDistributedMember(jgm); // logger.fine("DEBUG: created new dm addr " + mbr); // if a fully formed address, retain it in the map for future use if (sender.getVmKind() != 0 && createIfAbsent) { // logger.fine("DEBUG: adding to map " + sender + "->" + mbr); ipAddrToMemberMap.put(sender, mbr); } } // logger.fine("DEBUG: returning " + mbr); return mbr; } }
/** GemStoneAddition - return the weight of the given IDs */ public static int getWeight(Collection ids, Address leader) { int weight = 0; for (Iterator<IpAddress> it=ids.iterator(); it.hasNext(); ) { IpAddress addr = it.next(); int thisWeight = addr.getMemberWeight(); if (addr.getVmKind() == 10 /* NORMAL_DM_KIND */) { thisWeight += 10; if (leader != null && addr.equals(leader)) { thisWeight += 5; } } else if (addr.preferredForCoordinator()) { thisWeight += 3; } weight += thisWeight; } return weight; }
if (addr.getVmKind() != 10 /* NORMAL_DM_KIND */) { if (addr.preferredForCoordinator()) { failedWeight += 3;
/** * For Externalizable * * @see java.io.Externalizable */ public void writeExternal(ObjectOutput out) throws IOException { if (ipAddr == null) throw new InternalGemFireError(LocalizedStrings.JGroupMember_ATTEMPT_TO_EXTERNALIZE_NULL_IP_ADDRESS.toLocalizedString()); // ipAddr.writeExternal(out); // do it the way we like byte[] address = ipAddr.getIpAddress().getAddress(); out.writeInt(address.length); // IPv6 compatible out.write(address); out.writeInt(ipAddr.getPort()); out.write(ipAddr.getFlags()); Version.writeOrdinal(out, ipAddr.getVersionOrdinal(), true); byte bytes[] = new MemberAttributes(ipAddr.getDirectPort(), ipAddr.getProcessId(), ipAddr.getVmKind(), ipAddr.getBirthViewId(), ipAddr.getName(), ipAddr.getRoles(), (DurableClientAttributes)ipAddr.getDurableClientAttributes()).toByteArray(); if (bytes == null) out.writeInt(0); else { out.writeInt(bytes.length); out.write(bytes); } }
public MemberAttributes getAttributes() { return new MemberAttributes(ipAddr.getDirectPort(), ipAddr.getProcessId(), ipAddr.getVmKind(), ipAddr.getBirthViewId(), ipAddr.getName(), ipAddr.getRoles(), (DurableClientAttributes)ipAddr.getDurableClientAttributes()); }
IpAddress a = (IpAddress)it.next(); int thisWeight = a.getMemberWeight(); if (a.getVmKind() == 10 /* NORMAL_DM_KIND */) { thisWeight += 10; if (!leadProcessed) {
public void setPort(int p) { IpAddress i = new IpAddress(ipAddr.getIpAddress(), p); i.setFlags(ipAddr.getFlags()); i.setVmKind(ipAddr.getVmKind()); i.setDirectPort(ipAddr.getDirectPort()); i.setProcessId(ipAddr.getProcessId()); i.setRoles(ipAddr.getRoles()); i.setDurableClientAttributes(ipAddr.getDurableClientAttributes()); i.setVersionOrdinal(ipAddr.getVersionOrdinal()); this.ipAddr = i; } }