Takes a snapshot of the partition offsets.

<p>Important: This method must be called under the checkpoint lock.

@return A map from partition to current offset.
480149
public HashMap<KafkaTopicPartition, Long> snapshotCurrentState() {
		// this method assumes that the checkpoint lock is held
		assert Thread.holdsLock(checkpointLock);

		HashMap<KafkaTopicPartition, Long> state = new HashMap<>(subscribedPartitionStates.size());
		for (KafkaTopicPartitionState<KPH> partition : subscribedPartitionStates) {
			state.put(partition.getKafkaTopicPartition(), partition.getOffset());
		}
		return state;
	}
270147
private synchronized void getAllPreviousOffsetState(SourceState state) {
    if (this.doneGettingAllPreviousOffsets) {
      return;
    }
    this.previousOffsets.clear();
    this.previousLowWatermarks.clear();
    this.previousExpectedHighWatermarks.clear();
    this.previousOffsetFetchEpochTimes.clear();
    this.previousStartFetchEpochTimes.clear();
    this.previousStopFetchEpochTimes.clear();
    Map<String, Iterable<WorkUnitState>> workUnitStatesByDatasetUrns = state.getPreviousWorkUnitStatesByDatasetUrns();

    if (!workUnitStatesByDatasetUrns.isEmpty() &&
            !(workUnitStatesByDatasetUrns.size() == 1 && workUnitStatesByDatasetUrns.keySet().iterator().next()
        .equals(""))) {
      this.isDatasetStateEnabled.set(true);
    }

    for (WorkUnitState workUnitState : state.getPreviousWorkUnitStates()) {
      List<KafkaPartition> partitions = KafkaUtils.getPartitions(workUnitState);
      WorkUnit workUnit = workUnitState.getWorkunit();

      MultiLongWatermark watermark = workUnitState.getActualHighWatermark(MultiLongWatermark.class);
      MultiLongWatermark previousLowWatermark = workUnit.getLowWatermark(MultiLongWatermark.class);
      MultiLongWatermark previousExpectedHighWatermark = workUnit.getExpectedHighWatermark(MultiLongWatermark.class);
      Preconditions.checkArgument(partitions.size() == watermark.size(), String
          .format("Num of partitions doesn't match number of watermarks: partitions=%s, watermarks=%s", partitions,
              watermark));

      for (int i = 0; i < partitions.size(); i++) {
        KafkaPartition partition = partitions.get(i);

        if (watermark.get(i) != ConfigurationKeys.DEFAULT_WATERMARK_VALUE) {
          this.previousOffsets.put(partition, watermark.get(i));
        }

        if (previousLowWatermark.get(i) != ConfigurationKeys.DEFAULT_WATERMARK_VALUE) {
          this.previousLowWatermarks.put(partition, previousLowWatermark.get(i));
        }

        if (previousExpectedHighWatermark.get(i) != ConfigurationKeys.DEFAULT_WATERMARK_VALUE) {
          this.previousExpectedHighWatermarks.put(partition, previousExpectedHighWatermark.get(i));
        }

        this.previousOffsetFetchEpochTimes.put(partition,
            KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState(workUnitState, OFFSET_FETCH_EPOCH_TIME, i));

        this.previousStartFetchEpochTimes.put(partition,
            KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState(workUnitState, START_FETCH_EPOCH_TIME, i));

        this.previousStopFetchEpochTimes.put(partition,
            KafkaUtils.getPropAsLongFromSingleOrMultiWorkUnitState(workUnitState, STOP_FETCH_EPOCH_TIME, i));
      }
    }

    this.doneGettingAllPreviousOffsets = true;
  }
793243
@java.lang.Deprecated
  public java.util.Map<java.lang.String, java.lang.Long> getTotalBytesOnTiers() {
    return getTotalBytesOnTiersMap();
  }
858
private Map<String, Snapshot> getSnapshots() {
        /*
         * Use the individual snapshot directories instead of voltroot, because
         * they can be set individually
         */
        Map<String, SnapshotPathType> paths = new HashMap<String, SnapshotPathType>();
        if (VoltDB.instance().getConfig().m_isEnterprise) {
            if (m_clSnapshotPath != null) {
                paths.put(m_clSnapshotPath, SnapshotPathType.SNAP_CL);
            }
        }
        if (m_snapshotPath != null) {
            paths.put(m_snapshotPath, SnapshotPathType.SNAP_AUTO);
        }
        HashMap<String, Snapshot> snapshots = new HashMap<String, Snapshot>();
        FileFilter filter = new SnapshotUtil.SnapshotFilter();

        for (String path : paths.keySet()) {
            SnapshotUtil.retrieveSnapshotFiles(new File(path), snapshots, filter, false, paths.get(path), LOG);
        }

        return snapshots;
    }
363074
public Map<T, Integer> getMap() {
    return Maps.transformEntries(this.map,
      new EntryTransformer<T, AtomicInteger, Integer>() {
        @Override
        public Integer transformEntry(final T key, final AtomicInteger value) {
          return value.get();
        }
      });
  }
7872
private Observable<PartitionAndSeqno> getSeqnos() {
    return conductor.getSeqnos().flatMap(new Func1<ByteBuf, Observable<PartitionAndSeqno>>() {
      @Override
      public Observable<PartitionAndSeqno> call(ByteBuf buf) {
        int numPairs = buf.readableBytes() / 10; // 2 byte short + 8 byte long
        List<PartitionAndSeqno> pairs = new ArrayList<>(numPairs);
        for (int i = 0; i < numPairs; i++) {
          pairs.add(new PartitionAndSeqno(buf.getShort(10 * i), buf.getLong(10 * i + 2)));
        }
        buf.release();
        return Observable.from(pairs);
      }
    });
  }
81641
private Pair<Cluster, List<StoreDefinition>> getCurrentClusterState() {

        // Retrieve the latest cluster metadata from the existing nodes
        Versioned<Cluster> currentVersionedCluster = adminClient.rebalanceOps.getLatestCluster(Utils.nodeListToNodeIdList(Lists.newArrayList(adminClient.getAdminClientCluster()
                                                                                                                                                        .getNodes())));
        Cluster cluster = currentVersionedCluster.getValue();
        List<StoreDefinition> storeDefs = adminClient.rebalanceOps.getCurrentStoreDefinitions(cluster);
        return new Pair<Cluster, List<StoreDefinition>>(cluster, storeDefs);
    }
613431
public boolean isCheckpointingEnabled() {

		if (snapshotSettings == null) {
			return false;
		}

		long checkpointInterval = snapshotSettings.getCheckpointCoordinatorConfiguration().getCheckpointInterval();
		return checkpointInterval > 0 &&
			checkpointInterval < Long.MAX_VALUE;
	}
54125
public List<Long> getOffsets(OffsetRequest offsetRequest) {
        ILog log = getLog(offsetRequest.topic, offsetRequest.partition);
        if (log != null) {
            return log.getOffsetsBefore(offsetRequest);
        }
        return ILog.EMPTY_OFFSETS;
    }
542977
def merge_partition_offsets(*partition_offsets):
    
    output = dict()
    for partition_offset in partition_offsets:
        for partition, offset in six.iteritems(partition_offset):
            prev_offset = output.get(partition, 0)
            output[partition] = max(prev_offset, offset)
    return output
958904
public Map<String,Object> getProperty() {
		// TODO: If we have properties volatile, could do the null and frozen cases outside the synchronized block
		// TODO: Would this be faster?
		synchronized(lock) {
			if(properties == null) return Collections.emptyMap();
			if(frozen) return properties;
			return AoCollections.unmodifiableCopyMap(properties);
		}
	}
399469
public E poll() {

        final int readLocation = this.consumerReadLocation;

        // sets the nextReadLocation my moving it on by 1, this may cause it it wrap back to the start.
        final int nextReadLocation = (readLocation + 1 == capacity) ? 0 : readLocation + 1;

        if (writeLocation == readLocation)
            return null;

        // purposely not volatile as the read memory barrier occurred when we read 'writeLocation'
        final E value = data[readLocation];
        setReadLocation(nextReadLocation);

        return value;

    }
924070
public final long getRootDirOffset() {
        long sectSize = this.getBytesPerSector();
        long sectsPerFat = this.getSectorsPerFat();
        int fats = this.getNrFats();

        long offset = getFatOffset(0);
        
        offset += fats * sectsPerFat * sectSize;

        return offset;
    }
85059
CheckpointStatsHistory createSnapshot() {
		if (readOnly) {
			throw new UnsupportedOperationException("Can't create a snapshot of a read-only history.");
		}

		List<AbstractCheckpointStats> checkpointsHistory;
		Map<Long, AbstractCheckpointStats> checkpointsById;

		checkpointsById = new HashMap<>(checkpointsArray.length);

		if (maxSize == 0) {
			checkpointsHistory = Collections.emptyList();
		} else {
			AbstractCheckpointStats[] newCheckpointsArray = new AbstractCheckpointStats[checkpointsArray.length];

			System.arraycopy(checkpointsArray, nextPos, newCheckpointsArray, 0, checkpointsArray.length - nextPos);
			System.arraycopy(checkpointsArray, 0, newCheckpointsArray, checkpointsArray.length - nextPos, nextPos);

			checkpointsHistory = Arrays.asList(newCheckpointsArray);

			// reverse the order such that we start with the youngest checkpoint
			Collections.reverse(checkpointsHistory);

			for (AbstractCheckpointStats checkpoint : checkpointsHistory) {
				checkpointsById.put(checkpoint.getCheckpointId(), checkpoint);
			}
		}

		if (latestCompletedCheckpoint != null) {
			checkpointsById.put(latestCompletedCheckpoint.getCheckpointId(), latestCompletedCheckpoint);
		}

		if (latestFailedCheckpoint != null) {
			checkpointsById.put(latestFailedCheckpoint.getCheckpointId(), latestFailedCheckpoint);
		}

		if (latestSavepoint != null) {
			checkpointsById.put(latestSavepoint.getCheckpointId(), latestSavepoint);
		}

		return new CheckpointStatsHistory(
			true,
			maxSize,
			null,
			checkpointsHistory,
			checkpointsById,
			latestCompletedCheckpoint,
			latestFailedCheckpoint,
			latestSavepoint);
	}
412434
@Override
	public void snapshotState(StateSnapshotContext context) throws Exception {
		super.snapshotState(context);

		checkState(checkpointedState != null,
			"The operator state has not been properly initialized.");

		int subtaskIdx = getRuntimeContext().getIndexOfThisSubtask();

		checkpointedState.clear();

		List<TimestampedFileInputSplit> readerState = reader.getReaderState();

		try {
			for (TimestampedFileInputSplit split : readerState) {
				// create a new partition for each entry.
				checkpointedState.add(split);
			}
		} catch (Exception e) {
			checkpointedState.clear();

			throw new Exception("Could not add timestamped file input splits to to operator " +
				"state backend of operator " + getOperatorName() + '.', e);
		}

		if (LOG.isDebugEnabled()) {
			LOG.debug("{} (taskIdx={}) checkpointed {} splits: {}.",
				getClass().getSimpleName(), subtaskIdx, readerState.size(), readerState);
		}
	}
696708
@Override
  public long getAllocatedMemory() {
    long sum = 0;
    for (MapInternals m : segments) {
      sum += m.getAllocatedMemory();
    }
    return sum;
  }
45666
private byte[] getDiskBytes(long offset)
      throws IOException {
    mappedFile.seek(dataOffset + offset);

    //Get size of data
    int size = LongPacker.unpackInt(mappedFile);

    //Create output bytes
    byte[] res = new byte[size];

    //Read data
    if (mappedFile.read(res) == -1) {
      throw new EOFException();
    }

    return res;
  }