本文整理汇总了Java中org.apache.commons.lang3.tuple.ImmutablePair.getLeft方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutablePair.getLeft方法的具体用法?Java ImmutablePair.getLeft怎么用?Java ImmutablePair.getLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.tuple.ImmutablePair
的用法示例。
在下文中一共展示了ImmutablePair.getLeft方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findNodeByPodIP
import org.apache.commons.lang3.tuple.ImmutablePair; //导入方法依赖的package包/类
String findNodeByPodIP(String podIP) {
for (ImmutablePair<Netmask, ImmutableMap<NetworkAddress, String>> entry : podSubnetToNode) {
Netmask netmask = entry.getLeft();
ImmutableMap<NetworkAddress, String> networkToNode = entry.getRight();
// Computes the subnet that results from the netmask applied to the pod IP.
SubnetInfo podSubnetToCheck;
try {
podSubnetToCheck = new SubnetUtils(podIP, netmask.getValue()).getInfo();
} catch (IllegalArgumentException e) {
log.warn(e);
continue;
}
String networkAddress = podSubnetToCheck.getNetworkAddress();
String nodeName = networkToNode.get(new NetworkAddress(networkAddress));
if (nodeName != null) { // The cluster node is in charge of this pod IP subnet.
return nodeName;
}
}
return "";
}
示例2: getCustomRuleEventSpec
import org.apache.commons.lang3.tuple.ImmutablePair; //导入方法依赖的package包/类
/**
* Resolves event specification "<name> <alias> : <mode>". Uses default value when one not provided.
*
* @param eventSpecString event specification.
* @return rule event specification, i.e. a triple of (name, alias, mode).
*/
protected RuleEventSpec getCustomRuleEventSpec(String eventSpecString) {
if (eventSpecString == null) {
throw new SpongeException("Event specification is null");
}
List<String> mainList =
Arrays.stream(eventSpecString.split(":")).map(s -> s.trim()).filter(s -> !s.isEmpty()).collect(Collectors.toList());
if (mainList.isEmpty()) {
throw new SpongeException("Event specification is empty");
} else if (mainList.size() > 2) {
throw new SpongeException("Event specification has too many elements separated by ':'");
}
ImmutablePair<String, String> nameAlias = resolveEventNameAndAlias(mainList.get(0));
EventMode eventMode = RuleAdapter.DEFAULT_MODE;
if (mainList.size() == 2) {
try {
eventMode = EventMode.valueOf(mainList.get(1).toUpperCase());
} catch (Exception e) {
throw new SpongeException("Event mode is incorrect: " + mainList.get(1));
}
}
return new GenericRuleEventSpec(nameAlias.getLeft(), nameAlias.getRight(), eventMode);
}
示例3: getContent
import org.apache.commons.lang3.tuple.ImmutablePair; //导入方法依赖的package包/类
public String getContent() {
TableBuilder builder = new TableBuilder(OPERATOR_COLUMNS);
for (ImmutablePair<OperatorProfile, Integer> ip : ops) {
int minor = ip.getRight();
OperatorProfile op = ip.getLeft();
String path = new OperatorPathBuilder().setMajor(major).setMinor(minor).setOperator(op).build();
builder.appendCell(path, null);
builder.appendNanos(op.getSetupNanos(), null);
builder.appendNanos(op.getProcessNanos(), null);
builder.appendNanos(op.getWaitNanos(), null);
long maxBatches = Long.MIN_VALUE;
long maxRecords = Long.MIN_VALUE;
for (StreamProfile sp : op.getInputProfileList()) {
maxBatches = Math.max(sp.getBatches(), maxBatches);
maxRecords = Math.max(sp.getRecords(), maxRecords);
}
builder.appendFormattedInteger(maxBatches, null);
builder.appendFormattedInteger(maxRecords, null);
builder.appendBytes(op.getPeakLocalMemoryAllocated(), null);
}
return builder.build();
}
示例4: getContent
import org.apache.commons.lang3.tuple.ImmutablePair; //导入方法依赖的package包/类
public String getContent() {
TableBuilder builder = new TableBuilder(OPERATOR_COLUMNS);
for (ImmutablePair<OperatorProfile, Integer> ip : ops) {
int minor = ip.getRight();
OperatorProfile op = ip.getLeft();
String path = new OperatorPathBuilder().setMajor(major).setMinor(minor).setOperator(op).build();
builder.appendCell(path, null);
builder.appendNanos(op.getSetupNanos());
builder.appendNanos(op.getProcessNanos());
builder.appendNanos(op.getWaitNanos());
long maxBatches = Long.MIN_VALUE;
long maxRecords = Long.MIN_VALUE;
for (StreamProfile sp : op.getInputProfileList()) {
maxBatches = Math.max(sp.getBatches(), maxBatches);
maxRecords = Math.max(sp.getRecords(), maxRecords);
}
builder.appendFormattedInteger(maxBatches, null);
builder.appendFormattedInteger(maxRecords, null);
builder.appendBytes(op.getPeakLocalMemoryAllocated(), null);
}
return builder.build();
}
示例5: withinRange
import org.apache.commons.lang3.tuple.ImmutablePair; //导入方法依赖的package包/类
private boolean withinRange(final String name) {
final int queryNumber = session.getQueryCount();
final ImmutablePair<Integer, Integer> pair = shortLivedOptions.get(name);
final int start = pair.getLeft();
final int end = pair.getRight();
return start <= queryNumber && queryNumber < end;
}
示例6: addSummary
import org.apache.commons.lang3.tuple.ImmutablePair; //导入方法依赖的package包/类
public void addSummary(TableBuilder tb) {
String path = new OperatorPathBuilder().setMajor(major).setOperator(firstProfile).build();
tb.appendCell(path, null);
tb.appendCell(operatorType == null ? "UNKNOWN_OPERATOR" : operatorType.toString(), null);
double setupSum = 0.0;
double processSum = 0.0;
double waitSum = 0.0;
double memSum = 0.0;
for (ImmutablePair<OperatorProfile, Integer> ip : ops) {
OperatorProfile profile = ip.getLeft();
setupSum += profile.getSetupNanos();
processSum += profile.getProcessNanos();
waitSum += profile.getWaitNanos();
memSum += profile.getPeakLocalMemoryAllocated();
}
final ImmutablePair<OperatorProfile, Integer> shortSetup = Collections.min(ops, Comparators.setupTime);
final ImmutablePair<OperatorProfile, Integer> longSetup = Collections.max(ops, Comparators.setupTime);
tb.appendNanos(shortSetup.getLeft().getSetupNanos(), String.format(format, shortSetup.getRight()));
tb.appendNanos(Math.round(setupSum / size), null);
tb.appendNanos(longSetup.getLeft().getSetupNanos(), String.format(format, longSetup.getRight()));
final ImmutablePair<OperatorProfile, Integer> shortProcess = Collections.min(ops, Comparators.processTime);
final ImmutablePair<OperatorProfile, Integer> longProcess = Collections.max(ops, Comparators.processTime);
tb.appendNanos(shortProcess.getLeft().getProcessNanos(), String.format(format, shortProcess.getRight()));
tb.appendNanos(Math.round(processSum / size), null);
tb.appendNanos(longProcess.getLeft().getProcessNanos(), String.format(format, longProcess.getRight()));
final ImmutablePair<OperatorProfile, Integer> shortWait = Collections.min(ops, Comparators.waitTime);
final ImmutablePair<OperatorProfile, Integer> longWait = Collections.max(ops, Comparators.waitTime);
tb.appendNanos(shortWait.getLeft().getWaitNanos(), String.format(format, shortWait.getRight()));
tb.appendNanos(Math.round(waitSum / size), null);
tb.appendNanos(longWait.getLeft().getWaitNanos(), String.format(format, longWait.getRight()));
final ImmutablePair<OperatorProfile, Integer> peakMem = Collections.max(ops, Comparators.operatorPeakMemory);
tb.appendBytes(Math.round(memSum / size), null);
tb.appendBytes(peakMem.getLeft().getPeakLocalMemoryAllocated(), null);
}
示例7: addSummary
import org.apache.commons.lang3.tuple.ImmutablePair; //导入方法依赖的package包/类
public void addSummary(TableBuilder tb) {
String path = new OperatorPathBuilder().setMajor(major).setOperator(firstProfile).build();
tb.appendCell(path, null);
tb.appendCell(operatorName, null);
double setupSum = 0.0;
double processSum = 0.0;
double waitSum = 0.0;
double memSum = 0.0;
for (ImmutablePair<OperatorProfile, Integer> ip : ops) {
OperatorProfile profile = ip.getLeft();
setupSum += profile.getSetupNanos();
processSum += profile.getProcessNanos();
waitSum += profile.getWaitNanos();
memSum += profile.getPeakLocalMemoryAllocated();
}
final ImmutablePair<OperatorProfile, Integer> shortSetup = Collections.min(ops, Comparators.setupTime);
final ImmutablePair<OperatorProfile, Integer> longSetup = Collections.max(ops, Comparators.setupTime);
tb.appendNanos(shortSetup.getLeft().getSetupNanos());
tb.appendNanos(Math.round(setupSum / size));
tb.appendNanos(longSetup.getLeft().getSetupNanos());
final ImmutablePair<OperatorProfile, Integer> shortProcess = Collections.min(ops, Comparators.processTime);
final ImmutablePair<OperatorProfile, Integer> longProcess = Collections.max(ops, Comparators.processTime);
tb.appendNanos(shortProcess.getLeft().getProcessNanos());
tb.appendNanos(Math.round(processSum / size));
tb.appendNanos(longProcess.getLeft().getProcessNanos());
final ImmutablePair<OperatorProfile, Integer> shortWait = Collections.min(ops, Comparators.waitTime);
final ImmutablePair<OperatorProfile, Integer> longWait = Collections.max(ops, Comparators.waitTime);
tb.appendNanos(shortWait.getLeft().getWaitNanos());
tb.appendNanos(Math.round(waitSum / size));
tb.appendNanos(longWait.getLeft().getWaitNanos());
final ImmutablePair<OperatorProfile, Integer> peakMem = Collections.max(ops, Comparators.operatorPeakMemory);
tb.appendBytes(Math.round(memSum / size), null);
tb.appendBytes(peakMem.getLeft().getPeakLocalMemoryAllocated(), null);
}
示例8: getMetricsTable
import org.apache.commons.lang3.tuple.ImmutablePair; //导入方法依赖的package包/类
public String getMetricsTable() {
if (operatorType == null) {
return "";
}
final String[] metricNames = OperatorMetricRegistry.getMetricNames(operatorType.getNumber());
if (metricNames == null) {
return "";
}
final String[] metricsTableColumnNames = new String[metricNames.length + 1];
metricsTableColumnNames[0] = "Thread";
int i = 1;
for (final String metricName : metricNames) {
metricsTableColumnNames[i++] = metricName;
}
final TableBuilder builder = new TableBuilder(metricsTableColumnNames);
for (final ImmutablePair<OperatorProfile, Integer> ip : ops) {
final OperatorProfile op = ip.getLeft();
builder.appendCell(
new OperatorPathBuilder()
.setMajor(major)
.setMinor(ip.getRight())
.setOperator(op)
.build(),
null);
final Number[] values = new Number[metricNames.length];
for (final MetricValue metric : op.getMetricList()) {
if (metric.hasLongValue()) {
values[metric.getMetricId()] = metric.getLongValue();
} else if (metric.hasDoubleValue()) {
values[metric.getMetricId()] = metric.getDoubleValue();
}
}
for (final Number value : values) {
if (value != null) {
builder.appendFormattedNumber(value, null);
} else {
builder.appendCell("", null);
}
}
}
return builder.build();
}