Compress contiguous partitions into format "e-i" instead of
"e, f, g, h, i". This helps illustrate contiguous partitions within a
zone.

@param cluster
@param zoneId
@return pretty string of partitions per zone
517930
public static String compressedListOfPartitionsInZone(final Cluster cluster, int zoneId) {
        Map<Integer, Integer> idToRunLength = PartitionBalanceUtils.getMapOfContiguousPartitions(cluster,
                                                                                                 zoneId);

        StringBuilder sb = new StringBuilder();
        sb.append("[");
        boolean first = true;
        Set<Integer> sortedInitPartitionIds = new TreeSet<Integer>(idToRunLength.keySet());
        for(int initPartitionId: sortedInitPartitionIds) {
            if(!first) {
                sb.append(", ");
            } else {
                first = false;
            }

            int runLength = idToRunLength.get(initPartitionId);
            if(runLength == 1) {
                sb.append(initPartitionId);
            } else {
                int endPartitionId = (initPartitionId + runLength - 1)
                                     % cluster.getNumberOfPartitions();
                sb.append(initPartitionId).append("-").append(endPartitionId);
            }
        }
        sb.append("]");

        return sb.toString();
    }
624263
private Map<Integer, Integer> getNodeIdToZonePrimaryCount(Cluster cluster,
                                                              StoreRoutingPlan storeRoutingPlan) {
        Map<Integer, Integer> nodeIdToZonePrimaryCount = Maps.newHashMap();
        for(Integer nodeId: cluster.getNodeIds()) {
            nodeIdToZonePrimaryCount.put(nodeId,
                                         storeRoutingPlan.getZonePrimaryPartitionIds(nodeId).size());
        }

        return nodeIdToZonePrimaryCount;
    }
403998
public static String getFormatDate(String format, Date date, String zoneId) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(format);
        return dateTimeFormatter
            .format(date.toInstant().atZone(ZoneId.of(zoneId)).toLocalDateTime());
    }
1197368
private byte[] toCookedBytes()
    {
        // Allocate for a int pair per token/partition ID entry, plus a size.
        ByteBuffer buf = ByteBuffer.allocate(4 + (m_tokenCount * 8));

        buf.putInt(m_tokenCount);
        // Keep tokens and partition ids separate to aid compression.
        for (int zz = 3; zz >= 0; zz--) {
            int lastToken = Integer.MIN_VALUE;
            for (int ii = 0; ii < m_tokenCount; ii++) {
                int token = Bits.unsafe.getInt(m_tokens + (ii * 8));
                Preconditions.checkArgument(token >= lastToken);
                lastToken = token;
                token = token >>> (zz * 8);
                token = token & 0xFF;
                buf.put((byte)token);
            }
        }
        for (int ii = 0; ii < m_tokenCount; ii++) {
            buf.putInt(Bits.unsafe.getInt(m_tokens + (ii * 8) + 4));
        }

        try {
            return CompressionService.gzipBytes(buf.array());
        } catch (IOException e) {
            throw new RuntimeException("Failed to compress bytes", e);
        }
    }
133817
public static String decompressZlib(byte[] compressedData, long maxBytes) throws IOException {
        try (final ByteArrayInputStream dataStream = new ByteArrayInputStream(compressedData);
             final InflaterInputStream in = new InflaterInputStream(dataStream);
             final InputStream limited = ByteStreams.limit(in, maxBytes)) {
            return new String(ByteStreams.toByteArray(limited), StandardCharsets.UTF_8);
        }
    }
1200457
public String getClusterId(final String nodeId)
    {
        if (nodeId == null)
        {
            return null;
        }
        int dot = nodeId.lastIndexOf('.');
        return (dot > 0) ? nodeId.substring(0, dot) : nodeId;
    }
1037322
private static String normalizeClusterUrl(String clusterIdentifier) {
    try {
      URI uri = new URI(clusterIdentifier.trim());
      // URIs without protocol prefix
      if (!uri.isOpaque() && null != uri.getHost()) {
        clusterIdentifier = uri.getHost();
      } else {
        clusterIdentifier = uri.toString().replaceAll("[/:]"," ").trim().replaceAll(" ", "_");
      }
    } catch (URISyntaxException e) {
      //leave ID as is
    }

    return clusterIdentifier;
  }
622360
public void writeTo(String zoneID, OutputStream out) throws IOException {
        if (out instanceof DataOutput) {
            writeTo(zoneID, (DataOutput)out);
        } else {
            DataOutputStream dout = new DataOutputStream(out);
            writeTo(zoneID, (DataOutput)dout);
            dout.flush();
        }
    }
922985
private StringBuilder makeDescription(Cluster<?> c) {
    return new StringBuilder(200).append("<div>")//
        .append(c.getNameAutomatic())//
        .append("<br />")//
        .append("Size: ").append(c.size()) //
        .append("</div>");
  }
441435
public OvhRedirection zone_zoneName_redirection_id_GET(String zoneName, Long id) throws IOException {
		String qPath = "/domain/zone/{zoneName}/redirection/{id}";
		StringBuilder sb = path(qPath, zoneName, id);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhRedirection.class);
	}
569784
public static String changeFormatAndTimeZone(String isoTimestamp,
            String toBeTimeFormat, String zoneId) {
        return getTime(changeIsoTimestampToLong(isoTimestamp, zoneId),
                toBeTimeFormat, zoneId);
    }
140576
public static String getPrettyMapOfContiguousPartitionRunLengths(final Cluster cluster,
                                                                     int zoneId) {
        Map<Integer, Integer> runLengthToCount = getMapOfContiguousPartitionRunLengths(cluster,
                                                                                       zoneId);
        String prettyHistogram = "[";
        boolean first = true;
        Set<Integer> runLengths = new TreeSet<Integer>(runLengthToCount.keySet());
        for(int runLength: runLengths) {
            if(first) {
                first = false;
            } else {
                prettyHistogram += ", ";
            }
            prettyHistogram += "{" + runLength + " : " + runLengthToCount.get(runLength) + "}";
        }
        prettyHistogram += "]";
        return prettyHistogram;
    }
190691
public static ZoneId toZoneId(TimeZone tz) {
        // Android-changed: don't support "old mapping"
        return ZoneId.of(tz.getID(), ZoneId.SHORT_IDS);
    }
1226135
public OvhDynHostRecord zone_zoneName_dynHost_record_id_GET(String zoneName, Long id) throws IOException {
		String qPath = "/domain/zone/{zoneName}/dynHost/record/{id}";
		StringBuilder sb = path(qPath, zoneName, id);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhDynHostRecord.class);
	}
882981
public static long createFileId(long containerId) {
    long id = BlockId.createBlockId(containerId, BlockId.getMaxSequenceNumber());
    if (id == INVALID_FILE_ID) {
      // Right now, there's not much we can do if the file id we're returning is -1, since the file
      // id is completely determined by the container id passed in. However, by the current
      // algorithm, -1 will be the last file id generated, so the chances somebody will get to that
      // are slim. For now we just log it.
      LOG.warn("Created file id -1, which is invalid");
    }
    return id;
  }
1178695
private static void fillZoneStrings(String localeId, String[][] result) {
        for (int i = 0; i < result.length; i++) {
            fillZoneStringNames(localeId, result[i]);
        }
    }
439339
private static ZoneId ofWithPrefix(String zoneId, int prefixLength, boolean checkAvailable) {
        String prefix = zoneId.substring(0, prefixLength);
        if (zoneId.length() == prefixLength) {
            return ofOffset(prefix, ZoneOffset.UTC);
        }
        if (zoneId.charAt(prefixLength) != '+' && zoneId.charAt(prefixLength) != '-') {
            return ZoneRegion.ofId(zoneId, checkAvailable);  // drop through to ZoneRulesProvider
        }
        try {
            ZoneOffset offset = ZoneOffset.of(zoneId.substring(prefixLength));
            if (offset == ZoneOffset.UTC) {
                return ofOffset(prefix, offset);
            }
            return ofOffset(prefix, offset);
        } catch (DateTimeException ex) {
            throw new DateTimeException("Invalid ID for offset-based ZoneId: " + zoneId, ex);
        }
    }