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()); } }
public void readFields(DataInput in) throws IOException { hostName = Text.readString(in); frangmentCount = in.readLong(); updatable = in.readBoolean(); int replicaSize = in.readInt(); replicas = new ArrayList<ForestHost>(); for (int i=0; i < replicaSize; i++) { String curForest = Text.readString(in); String curHost = Text.readString(in); ForestHost fh = new ForestHost(curForest, curHost); replicas.add(fh); } }
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)); } }
@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 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 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(); }
@Override public void readFields(DataInput in) throws IOException { start = in.readLong(); length = in.readLong(); Text forestIdText = new Text(); forestIdText.readFields(in); forestId = new BigInteger(forestIdText.getBytes()); hostName = new String[1]; hostName[0] = Text.readString(in); isLastSplit = in.readBoolean(); int replicaSize = in.readInt(); replicas = new ArrayList<ForestHost>(); for (int i=0; i < replicaSize; i++) { String curForest = Text.readString(in); String curHost = Text.readString(in); ForestHost fh = new ForestHost(curForest, curHost); replicas.add(fh); } }
ContentSource cs = hostSourceMap.get(replicas.get(curReplica[fId]).getHostName()); String forestId = replicas.get(curReplica[fId]).getForest(); session = cs.newSession(ID_PREFIX + forestId); if (LOG.isDebugEnabled()) {
} else if (index == 1) { curHost = item.asString(); ForestHost info = new ForestHost(curForest, curHost); replicas.add(info); ForestHost info = new ForestHost(forest.toString(), hostName); replicas.add(info);
curHostName = hostNames[0]; } else { curForestName = replicas.get(curForest).getForest(); curHostName = replicas.get(curForest).getHostName();
replicaHost = inputHosts[0]; ForestHost info = new ForestHost(replicaForest, replicaHost); replicas.add(info);
for (int i = 0; i < forestHostList.size(); i++) { ForestHost fh = forestHostList.get(i); String forestIdStr = fh.getForest(); String forestHost = fh.getHostName(); String targetHost = restrictHosts? rhUtil.getNextHost(forestHost):forestHost;
curHostName = hostNames[0]; } else { curForestName = replicas.get(curForest).getForest(); curHostName = replicas.get(curForest).getHostName();