final String sessionId() { return context.getId(); }
final String sessionId() { return context.getId(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Session ").append(context().getId()).append(" (readonly) to workspace '").append(workspaceName()); return sb.toString(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Session ").append(context().getId()).append(" (readonly) to workspace '").append(workspaceName()); return sb.toString(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); NamespaceRegistry reg = context().getNamespaceRegistry(); sb.append("Session ").append(context().getId()).append(" to workspace '").append(workspaceName()); for (NodeKey key : changedNodesInOrder) { SessionNode changes = changedNodes.get(key); if (changes == null) { continue; } sb.append("\n "); sb.append(changes.getString(reg)); } return sb.toString(); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); NamespaceRegistry reg = context().getNamespaceRegistry(); sb.append("Session ").append(context().getId()).append(" to workspace '").append(workspaceName()); for (NodeKey key : changedNodesInOrder) { SessionNode changes = changedNodes.get(key); if (changes == null) { continue; } sb.append("\n "); sb.append(changes.getString(reg)); } return sb.toString(); } }
@Test public void shouldHaveIdentifierThatIsUnique() { // Can't really test this, but we certainly can test that there are no duplicates in many contexts ... Set<String> ids = new HashSet<String>(); for (int i = 0; i != 50; ++i) { assertThat(ids.add(new ExecutionContext().getId()), is(true)); } }
protected final void logChangesBeingSaved(Iterable<NodeKey> firstNodesInOrder, Iterable<NodeKey> secondNodesInOrder) { if (SAVE_LOGGER.isTraceEnabled()) { String txn = txns.currentTransactionId(); // // Determine if there are any changes to be made. Note that this number is generally between 1 and 100, // // though for high concurrency some numbers may go above 100. However, the 100th save will always reset // // the counter back down to 1. (Any thread that got a save number above 100 will simply use it.) final int s = SAVE_NUMBER.getAndIncrement(); if (s == MAX_SAVE_NUMBER) SAVE_NUMBER.set(1); // only the 100th final AtomicInteger changes = new AtomicInteger(0); // There are at least some changes ... ExecutionContext context = getContext(); String id = context.getId(); String username = context.getSecurityContext().getUserName(); NamespaceRegistry registry = context.getNamespaceRegistry(); if (username == null) username = "<anonymous>"; SAVE_LOGGER.trace("Save #{0} (part of transaction '{1}') by session {2}({3}) is persisting the following changes:", s, txn, username, id); UnionIterator<NodeKey> unionIterator = new UnionIterator<>(firstNodesInOrder.iterator(), secondNodesInOrder); unionIterator.forEachRemaining(key -> { SessionNode node = changedNodes.get(key); if (node != null && node.hasChanges()) { SAVE_LOGGER.trace(" #{0} {1}", s, node.getString(registry)); changes.incrementAndGet(); } }); SAVE_LOGGER.trace("Save #{0} (part of transaction '{1}') by session {2}({3}) completed persisting changes to {4} nodes", s, txn, username, id, changes.get()); } }
protected final void logChangesBeingSaved(Iterable<NodeKey> firstNodesInOrder, Iterable<NodeKey> secondNodesInOrder) { if (SAVE_LOGGER.isTraceEnabled()) { String txn = txns.currentTransactionId(); // // Determine if there are any changes to be made. Note that this number is generally between 1 and 100, // // though for high concurrency some numbers may go above 100. However, the 100th save will always reset // // the counter back down to 1. (Any thread that got a save number above 100 will simply use it.) final int s = SAVE_NUMBER.getAndIncrement(); if (s == MAX_SAVE_NUMBER) SAVE_NUMBER.set(1); // only the 100th final AtomicInteger changes = new AtomicInteger(0); // There are at least some changes ... ExecutionContext context = getContext(); String id = context.getId(); String username = context.getSecurityContext().getUserName(); NamespaceRegistry registry = context.getNamespaceRegistry(); if (username == null) username = "<anonymous>"; SAVE_LOGGER.trace("Save #{0} (part of transaction '{1}') by session {2}({3}) is persisting the following changes:", s, txn, username, id); UnionIterator<NodeKey> unionIterator = new UnionIterator<>(firstNodesInOrder.iterator(), secondNodesInOrder); unionIterator.forEachRemaining(key -> { SessionNode node = changedNodes.get(key); if (node != null && node.hasChanges()) { SAVE_LOGGER.trace(" #{0} {1}", s, node.getString(registry)); changes.incrementAndGet(); } }); SAVE_LOGGER.trace("Save #{0} (part of transaction '{1}') by session {2}({3}) completed persisting changes to {4} nodes", s, txn, username, id, changes.get()); } }
@Test public void shouldHaveIdentifierThatIsNotNull() { assertThat(context.getId(), is(notNullValue())); }
public final void setAccessControlEnabled( boolean enabled ) { if (this.accessControlEnabled.compareAndSet(!enabled, enabled)) { refreshRepositoryMetadata(true); // And notify the others ... String userId = context.getSecurityContext().getUserName(); Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.repositoryMetadataChanged(); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); } }
public final void setAccessControlEnabled( boolean enabled ) { if (this.accessControlEnabled.compareAndSet(!enabled, enabled)) { refreshRepositoryMetadata(true); // And notify the others ... String userId = context.getSecurityContext().getUserName(); Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.repositoryMetadataChanged(); changes.freeze(userId, userData, timestamp); this.changeBus.notify(changes); } }
private ConnectorChangeSetFactory createConnectorChangedSetFactory( final Connector c ) { return () -> { PathMappings mappings = getPathMappings(c); RunningState repository1 = repository(); final ExecutionContext context = repository1.context(); return new ConnectorChangeSetImpl(Connectors.this, mappings, context.getId(), context.getProcessId(), repository1.repositoryKey(), repository1.changeBus(), context.getValueFactories().getDateFactory(), repository().journalId()); }; }
private ConnectorChangeSetFactory createConnectorChangedSetFactory( final Connector c ) { return () -> { PathMappings mappings = getPathMappings(c); RunningState repository1 = repository(); final ExecutionContext context = repository1.context(); return new ConnectorChangeSetImpl(Connectors.this, mappings, context.getId(), context.getProcessId(), repository1.repositoryKey(), repository1.changeBus(), context.getValueFactories().getDateFactory(), repository().journalId()); }; }
Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.workspaceRemoved(name);
Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.workspaceAdded(name);
Map<String, String> userData = context.getData(); DateTime timestamp = context.getValueFactories().getDateFactory().create(); RecordingChanges changes = new RecordingChanges(context.getId(), context.getProcessId(), this.getKey(), null, repositoryEnvironment.journalId()); changes.workspaceAdded(name);