List of usage examples for com.google.common.primitives UnsignedLong MAX_VALUE
UnsignedLong MAX_VALUE
To view the source code for com.google.common.primitives UnsignedLong MAX_VALUE.
Click Source Link
From source file:net.floodlightcontroller.core.web.SwitchResourceBase.java
/** * Use for requests that originate from the REST server that use their context to get a * reference to the switch service.//from w w w. jav a2 s . com * @param switchId * @param statType * @return */ @SuppressWarnings("unchecked") @LogMessageDoc(level = "ERROR", message = "Failure retrieving statistics from switch {switch}", explanation = "An error occurred while retrieving statistics" + "from the switch", recommendation = LogMessageDoc.CHECK_SWITCH + " " + LogMessageDoc.GENERIC_ACTION) protected List<OFStatsReply> getSwitchStatistics(DatapathId switchId, OFStatsType statType) { IOFSwitchService switchService = (IOFSwitchService) getContext().getAttributes() .get(IOFSwitchService.class.getCanonicalName()); IOFSwitch sw = switchService.getSwitch(switchId); ListenableFuture<?> future; List<OFStatsReply> values = null; Match match; if (sw != null) { OFStatsRequest<?> req = null; switch (statType) { case FLOW: match = sw.getOFFactory().buildMatch().build(); req = sw.getOFFactory().buildFlowStatsRequest().setMatch(match).setOutPort(OFPort.ANY) .setTableId(TableId.ALL).build(); break; case AGGREGATE: match = sw.getOFFactory().buildMatch().build(); req = sw.getOFFactory().buildAggregateStatsRequest().setMatch(match).setOutPort(OFPort.ANY) .setTableId(TableId.ALL).build(); break; case PORT: req = sw.getOFFactory().buildPortStatsRequest().setPortNo(OFPort.ANY).build(); break; case QUEUE: req = sw.getOFFactory().buildQueueStatsRequest().setPortNo(OFPort.ANY) .setQueueId(UnsignedLong.MAX_VALUE.longValue()).build(); break; case DESC: // pass - nothing todo besides set the type above req = sw.getOFFactory().buildDescStatsRequest().build(); break; case GROUP: if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_10) > 0) { req = sw.getOFFactory().buildGroupStatsRequest().build(); } break; case METER: if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_13) >= 0) { req = sw.getOFFactory().buildMeterStatsRequest().setMeterId(OFMeterSerializerVer13.ALL_VAL) .build(); } break; case GROUP_DESC: if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_10) > 0) { req = sw.getOFFactory().buildGroupDescStatsRequest().build(); } break; case GROUP_FEATURES: if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_10) > 0) { req = sw.getOFFactory().buildGroupFeaturesStatsRequest().build(); } break; case METER_CONFIG: if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_13) >= 0) { req = sw.getOFFactory().buildMeterConfigStatsRequest().build(); } break; case METER_FEATURES: if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_13) >= 0) { req = sw.getOFFactory().buildMeterFeaturesStatsRequest().build(); } break; case TABLE: if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_10) > 0) { req = sw.getOFFactory().buildTableStatsRequest().build(); } break; case TABLE_FEATURES: if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_10) > 0) { req = sw.getOFFactory().buildTableFeaturesStatsRequest().build(); } break; case PORT_DESC: if (sw.getOFFactory().getVersion().compareTo(OFVersion.OF_13) >= 0) { req = sw.getOFFactory().buildPortDescStatsRequest().build(); } break; case EXPERIMENTER: //TODO @Ryan support new OF1.1+ stats types default: log.error("Stats Request Type {} not implemented yet", statType.name()); break; } try { if (req != null) { future = sw.writeStatsRequest(req); values = (List<OFStatsReply>) future.get(10, TimeUnit.SECONDS); } } catch (Exception e) { log.error("Failure retrieving statistics from switch " + sw, e); } } return values; }
From source file:se.sics.caracaldb.global.DefaultPolicy.java
private Set<Key> generateVNodes(byte[] schemaId, int num) { Set<Key> keys = new TreeSet<Key>(); // boundary nodes Key start = new Key(schemaId); keys.add(start);//from www .ja va 2s . c o m //virtualHostsPut(end, rset); // this mind end up being override by the next schema, but that's ok since we only need it if there is no next schema if (num == 1) { // single vnode needed return keys; } num--; // account for the initial vnode already created (the end-nodes doesn't count) if (num <= UnsignedBytes.MAX_VALUE) { // another byte for subkeys needed int incr = (int) UnsignedBytes.MAX_VALUE / (int) num; int last = 0; int ceiling = (int) UnsignedBytes.MAX_VALUE - incr; while (last < ceiling) { last = last + incr; Key k = start.append(new byte[] { UnsignedBytes.saturatedCast(last) }).get(); keys.add(k); } } else if (num <= UnsignedInteger.MAX_VALUE.longValue()) { // another 4 bytes for subkeys needed long incr = UnsignedInteger.MAX_VALUE.longValue() / num; long last = 0; long ceiling = UnsignedInteger.MAX_VALUE.longValue() - incr; while (last < ceiling) { last = last + incr; Key k = start.append(new Key(UnsignedInteger.valueOf(last).intValue())).get(); keys.add(k); } } else { // another 8 bytes for subkeys needed (don't support more!) UnsignedLong incr = UnsignedLong.MAX_VALUE.dividedBy(UnsignedLong.valueOf(num)); UnsignedLong last = UnsignedLong.ZERO; UnsignedLong ceiling = UnsignedLong.MAX_VALUE.minus(incr); while (last.compareTo(ceiling) <= 0) { last = last.plus(incr); Key k = start.append(new Key(last.intValue())).get(); keys.add(k); } } return keys; }
From source file:se.sics.caracaldb.global.LookupTable.java
private void generateInitialVirtuals(ByteBuffer schemaId) { ImmutableMap<String, String> meta = schemas.metaData.get(schemaId); //String rfactorS = meta.getOrDefault("rfactor", "3"); String rfactorS = J6.orDefault(meta.get("rfactor"), "3"); Integer rfactor = Integer.parseInt(rfactorS); //String vnodesS = meta.getOrDefault("vnodes", "1"); String vnodesS = J6.orDefault(meta.get("vnodes"), "1"); long vnodes = Long.parseLong(vnodesS); //String forceMasterS = meta.getOrDefault("forceMaster", "false"); String forceMasterS = J6.orDefault(meta.get("forceMaster"), "false"); // it would look so nice in Java8 -.- boolean forceMaster = Boolean.parseBoolean(forceMasterS); // boundary nodes Key start = new Key(schemaId); //Key end = start.inc(); Integer rset = forceMaster ? 0 : findReplicationSetOfSize(rfactor); virtualHostsPut(start, rset);// w ww .ja va 2 s.c o m //virtualHostsPut(end, rset); // this mind end up being override by the next schema, but that's ok since we only need it if there is no next schema if (vnodes == 1) { // single vnode needed return; } vnodes--; // account for the initial vnode already created (the end-nodes doesn't count) Set<Key> subkeys = new TreeSet<Key>(); if (vnodes <= UnsignedBytes.MAX_VALUE) { // another byte for subkeys needed int incr = (int) UnsignedBytes.MAX_VALUE / (int) vnodes; int last = 0; int ceiling = (int) UnsignedBytes.MAX_VALUE - incr; while (last < ceiling) { last = last + incr; Key k = start.append(new byte[] { UnsignedBytes.saturatedCast(last) }).get(); subkeys.add(k); } } else if (vnodes <= UnsignedInteger.MAX_VALUE.longValue()) { // another 4 bytes for subkeys needed long incr = UnsignedInteger.MAX_VALUE.longValue() / vnodes; long last = 0; long ceiling = UnsignedInteger.MAX_VALUE.longValue() - incr; while (last < ceiling) { last = last + incr; Key k = start.append(new Key(UnsignedInteger.valueOf(last).intValue())).get(); subkeys.add(k); } } else { // another 8 bytes for subkeys needed (don't support more!) UnsignedLong incr = UnsignedLong.MAX_VALUE.dividedBy(UnsignedLong.valueOf(vnodes)); UnsignedLong last = UnsignedLong.ZERO; UnsignedLong ceiling = UnsignedLong.MAX_VALUE.minus(incr); while (last.compareTo(ceiling) <= 0) { last = last.plus(incr); Key k = start.append(new Key(last.intValue())).get(); subkeys.add(k); } } for (Key subkey : subkeys) { virtualHostsPut(subkey, forceMaster ? 0 : findReplicationSetOfSize(rfactor)); } }