@Nonnull @Override public Map<String, String> checkpointInfo(@Nonnull String checkpoint) { return getNodeStore().checkpointInfo(checkpoint); }
@NotNull @Override public Map<String, String> checkpointInfo(@NotNull String checkpoint) { return getNodeStore().checkpointInfo(checkpoint); }
@NotNull @Override public Map<String, String> checkpointInfo(@NotNull String checkpoint) { if (inheritedCheckpoints.contains(checkpoint)) { return nodeStore.checkpointInfo(checkpoint); } else if (checkpointMapping.containsKey(checkpoint)) { return memoryNodeStore.checkpointInfo(checkpointMapping.get(checkpoint)); } else { return emptyMap(); } }
@NotNull @Override public Map<String, String> checkpointInfo(@NotNull String checkpoint) { return getNodeStore().checkpointInfo(checkpoint); }
@NotNull @Override public Map<String, String> checkpointInfo(@NotNull String checkpoint) { if (inheritedCheckpoints.contains(checkpoint)) { return nodeStore.checkpointInfo(checkpoint); } else if (checkpointMapping.containsKey(checkpoint)) { return memoryNodeStore.checkpointInfo(checkpointMapping.get(checkpoint)); } else { return emptyMap(); } }
@NotNull @Override public Map<String, String> checkpointInfo(@NotNull String checkpoint) { return getNodeStore().checkpointInfo(checkpoint); }
@Nonnull @Override public Map<String, String> checkpointInfo(@Nonnull String checkpoint) { return getNodeStore().checkpointInfo(checkpoint); }
@Nonnull @Override public Map<String, String> checkpointInfo(@Nonnull String checkpoint) { if (inheritedCheckpoints.contains(checkpoint)) { return nodeStore.checkpointInfo(checkpoint); } else if (checkpointMapping.containsKey(checkpoint)) { return memoryNodeStore.checkpointInfo(checkpointMapping.get(checkpoint)); } else { return emptyMap(); } }
public void dispose() { for (String cp : nodeStore.checkpoints()) { if ("copy-on-write".equals(nodeStore.checkpointInfo(cp).get("type"))) { nodeStore.release(cp); } } }
public void dispose() { for (String cp : nodeStore.checkpoints()) { if ("copy-on-write".equals(nodeStore.checkpointInfo(cp).get("type"))) { nodeStore.release(cp); } } }
public void dispose() { for (String cp : nodeStore.checkpoints()) { if ("copy-on-write".equals(nodeStore.checkpointInfo(cp).get("type"))) { nodeStore.release(cp); } } }
private boolean isCompositeCheckpoint(String checkpoint) { Map<String, String> props = ctx.getGlobalStore().getNodeStore().checkpointInfo(checkpoint); if (props == null) { return false; } return props.containsKey(CHECKPOINT_METADATA + "created"); }
Map<String, String> allCheckpointInfo(String checkpoint) { return ctx.getGlobalStore().getNodeStore().checkpointInfo(checkpoint); }
private String getPartialCheckpointName(MountedNodeStore nodeStore, String globalCheckpoint, Map<String, String> globalCheckpointProperties, boolean resolveByName) { Set<String> validCheckpointNames = ImmutableSet.copyOf(nodeStore.getNodeStore().checkpoints()); String result = globalCheckpointProperties.get(CHECKPOINT_METADATA_MOUNT + nodeStore.getMount().getName()); if (result != null && validCheckpointNames.contains(result)) { return result; } if (globalCheckpoint != null && validCheckpointNames.contains(globalCheckpoint)) { return globalCheckpoint; } if (resolveByName) { String nameProp = globalCheckpointProperties.get("name"); if (nameProp == null) { return null; } for (String c : validCheckpointNames) { Map<String, String> partialCheckpointProperties = nodeStore.getNodeStore().checkpointInfo(c); if (nameProp.equals(partialCheckpointProperties.get("name"))) { return c; } } } return null; }
@Override public Map<String, String> checkpointInfo(String checkpoint) { if (!checkpointExists(ctx.getGlobalStore().getNodeStore(), checkpoint)) { LOG.warn("Checkpoint {} doesn't exist. Debug info:\n{}", checkpoint, checkpointDebugInfo()); return Collections.emptyMap(); } return copyOf(filterKeys(ctx.getGlobalStore().getNodeStore().checkpointInfo(checkpoint), new Predicate<String>() { @Override public boolean apply(String input) { return !input.startsWith(CHECKPOINT_METADATA); } })); }
@Override public long getOldestCheckpointCreationTimestamp() { Iterable<String> checkpoints = nodeStore.checkpoints(); long minCreationDate = Long.MAX_VALUE; for (String checkpoint : checkpoints) { Map<String, String> chkInfo = nodeStore.checkpointInfo(checkpoint); if (chkInfo.containsKey(CREATION_DATE) && Long.valueOf(chkInfo.get(CREATION_DATE)) < minCreationDate) { minCreationDate = Long.valueOf(chkInfo.get(CREATION_DATE)); } } if (minCreationDate == Long.MAX_VALUE) { minCreationDate = 0; } return minCreationDate; }
@Override public boolean release(String checkpoint) { Map<String, String> props; boolean result; if (checkpointExists(ctx.getGlobalStore().getNodeStore(), checkpoint)) { props = ctx.getGlobalStore().getNodeStore().checkpointInfo(checkpoint); result = ctx.getGlobalStore().getNodeStore().release(checkpoint); } else { props = Collections.emptyMap(); result = true; } if (LOG.isDebugEnabled()) { LOG.debug("Released checkpoint {}. Result: {}. Debug info:\n{}", checkpoint, result, checkpointDebugInfo()); } return result; }
@Test public void checkpointInfo() throws CommitFailedException { ImmutableMap<String, String> props = ImmutableMap.of( "one", "1", "two", "2", "three", "2"); String cp = store.checkpoint(Long.MAX_VALUE, props); assertEquals(props, store.checkpointInfo(cp)); }
@Test public void checkpointsInCowMode() throws CommitFailedException { String checkpoint1 = cowNodeStore.checkpoint(Long.MAX_VALUE, of("k", "v")); cowNodeStore.enableCopyOnWrite(); Map<String, String> info = cowNodeStore.checkpointInfo(checkpoint1); assertEquals("The checkpoint is not inherited", of("k", "v"), info); NodeState root = cowNodeStore.getRoot(); NodeBuilder builder = root.builder(); builder.child("foo"); cowNodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); String checkpoint2 = cowNodeStore.checkpoint(Long.MAX_VALUE, of("k", "v2")); info = cowNodeStore.checkpointInfo(checkpoint2); assertEquals("The new checkpoint is not available", of("k", "v2"), info); assertTrue("The retrieve() doesn't work for the new checkpoint", cowNodeStore.retrieve(checkpoint2).hasChildNode("foo")); assertEquals(ImmutableList.of(checkpoint1, checkpoint2), cowNodeStore.checkpoints()); assertTrue("The new checkpoint shouldn't be stored in the main store", store.checkpointInfo(checkpoint2).isEmpty()); cowNodeStore.disableCopyOnWrite(); assertTrue("The new checkpoint should be dropped after disabling the CoW mode", cowNodeStore.checkpointInfo(checkpoint2).isEmpty()); } }
protected void verifyCheckpoint() { assertEquals("after", destination.getRoot().getString("checkpoint-state")); String checkpointReference = null; for (String c : destination.checkpoints()) { if (destination.checkpointInfo(c).containsKey("key")) { checkpointReference = c; break; } } assertNotNull(checkpointReference); Map<String, String> info = destination.checkpointInfo(checkpointReference); assertEquals("123", info.get("key")); NodeState checkpoint = destination.retrieve(checkpointReference); assertEquals("before", checkpoint.getString("checkpoint-state")); assertEquals("123", destination.getRoot().getChildNode(":async").getString("test")); for (String name : new String[] {"var", "etc", "sling.css", "apps", "libs", "sightly"}) { assertSameRecord(destination.getRoot().getChildNode(name), checkpoint.getChildNode(name)); } }