public ForestInfo(String hostName, long fmCount, boolean updatable, List<ForestHost> replicas) { super(); this.hostName = hostName; this.frangmentCount = fmCount; this.updatable = updatable; this.replicas = new ArrayList<ForestHost>(); int start = 0; int len = replicas.size(); /* find the current open forest * use hostname to compare because forest is the same for shared-disk failover */ for (int i = 0; i < len; i++) { if (hostName.equals(replicas.get(i).getHostName())) { start = i; break; } } /* reorder the list so that the open forest is the first in the list */ for (int i = start; i < len; i++) { this.replicas.add(replicas.get(i)); } for (int i = 0; i < start; i++) { this.replicas.add(replicas.get(i)); } }
public void write(DataOutput out) throws IOException { Text.writeString(out, hostName); out.writeLong(frangmentCount); out.writeBoolean(updatable); int replicaSize = replicas.size(); out.writeInt(replicaSize); for (int i=0; i < replicaSize; i++) { Text.writeString(out, replicas.get(i).getForest()); Text.writeString(out, replicas.get(i).getHostName()); } }
@Override public void write(DataOutput out) throws IOException { out.writeLong(start); out.writeLong(length); Text forestIdText = new Text(forestId.toByteArray()); forestIdText.write(out); if (hostName != null && hostName.length > 0) { Text.writeString(out, hostName[0]); } out.writeBoolean(isLastSplit); int replicaSize = (replicas != null) ? replicas.size() : 0; out.writeInt(replicaSize); for (int i=0; i < replicaSize; i++) { Text.writeString(out, replicas.get(i).getForest()); Text.writeString(out, replicas.get(i).getHostName()); } }
@Override public void initialize(InputSplit inSplit, TaskAttemptContext context) throws IOException, InterruptedException { mlSplit = (MarkLogicInputSplit) inSplit; count = 0; nakedCount = 0; context.getCounter(MarkLogicCounter.ESTIMATED_INPUT_RECORDS) .increment(mlSplit.getLength()); // construct the server URI hostNames = mlSplit.getLocations(); if (hostNames == null || hostNames.length < 1) { throw new IllegalStateException("Empty split locations."); } if (LOG.isDebugEnabled()) { LOG.debug("split location: " + hostNames[0]); } replicas = mlSplit.getReplicas(); curForest = -1; if (replicas != null) { for (int i = 0; i < replicas.size(); i++) { if (replicas.get(i).getHostName().equals(hostNames[0])) { curForest = i; break; } } } retry = 0; sleepTime = 500; init(); }
@Override public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { mlSplit = (MarkLogicInputSplit)split; count = 0; context.getCounter(MarkLogicCounter.ESTIMATED_INPUT_RECORDS) .increment(mlSplit.getLength()); // check hostnames hostNames = mlSplit.getLocations(); if (hostNames == null || hostNames.length < 1) { throw new IllegalStateException("Empty split locations."); } if (LOG.isDebugEnabled()) { LOG.debug("split location: " + hostNames[0]); } replicas = mlSplit.getReplicas(); curForest = -1; if (replicas != null) { for (int i = 0; i < replicas.size(); i++) { if (replicas.get(i).getHostName().equals(hostNames[0])) { curForest = i; break; } } } retry = 0; sleepTime = 500; init(); }
ContentSource cs = hostSourceMap.get(replicas.get(curReplica[fId]).getHostName()); String forestId = replicas.get(curReplica[fId]).getForest(); session = cs.newSession(ID_PREFIX + forestId);
} else { curForestName = replicas.get(curForest).getForest(); curHostName = replicas.get(curForest).getHostName();
} else { curForestName = replicas.get(curForest).getForest(); curHostName = replicas.get(curForest).getHostName();
ForestHost fh = forestHostList.get(i); String forestIdStr = fh.getForest(); String forestHost = fh.getHostName(); String targetHost = restrictHosts? rhUtil.getNextHost(forestHost):forestHost;