Prefixing log message with shard name is useful to track things
down. Pass the shard name down from FrontendMetadata, so we can
emit such messages.
Change-Id: Ie6a2cd218e1a2686f8cc14f67574f245e3de914b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
cd6996f873c6d98b642a0f6f725babed67e211f1)
private final Map<LocalHistoryIdentifier, FrontendHistoryMetadataBuilder> currentHistories = new HashMap<>();
private final RangeSet<UnsignedLong> purgedHistories;
private final ClientIdentifier identifier;
private final Map<LocalHistoryIdentifier, FrontendHistoryMetadataBuilder> currentHistories = new HashMap<>();
private final RangeSet<UnsignedLong> purgedHistories;
private final ClientIdentifier identifier;
+ private final String shardName;
- FrontendClientMetadataBuilder(final ClientIdentifier identifier) {
+ FrontendClientMetadataBuilder(final String shardName, final ClientIdentifier identifier) {
+ this.shardName = Preconditions.checkNotNull(shardName);
this.identifier = Preconditions.checkNotNull(identifier);
purgedHistories = TreeRangeSet.create();
this.identifier = Preconditions.checkNotNull(identifier);
purgedHistories = TreeRangeSet.create();
currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
}
currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
}
- FrontendClientMetadataBuilder(final FrontendClientMetadata meta) {
+ FrontendClientMetadataBuilder(final String shardName, final FrontendClientMetadata meta) {
+ this.shardName = Preconditions.checkNotNull(shardName);
this.identifier = Preconditions.checkNotNull(meta.getIdentifier());
purgedHistories = TreeRangeSet.create(meta.getPurgedHistories());
this.identifier = Preconditions.checkNotNull(meta.getIdentifier());
purgedHistories = TreeRangeSet.create(meta.getPurgedHistories());
// Sanity check and recovery
final LocalHistoryIdentifier standaloneId = standaloneHistoryId();
if (!currentHistories.containsKey(standaloneId)) {
// Sanity check and recovery
final LocalHistoryIdentifier standaloneId = standaloneHistoryId();
if (!currentHistories.containsKey(standaloneId)) {
- LOG.warn("Client {} recovered histories {} do not contain stand-alone history, attempting recovery",
- identifier, currentHistories);
+ LOG.warn("{}: Client {} recovered histories {} do not contain stand-alone history, attempting recovery",
+ shardName, identifier, currentHistories);
currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
}
}
currentHistories.put(standaloneId, new FrontendHistoryMetadataBuilder(standaloneId));
}
}
final FrontendHistoryMetadataBuilder oldMeta = currentHistories.putIfAbsent(historyId, newMeta);
if (oldMeta != null) {
// This should not be happening, warn about it
final FrontendHistoryMetadataBuilder oldMeta = currentHistories.putIfAbsent(historyId, newMeta);
if (oldMeta != null) {
// This should not be happening, warn about it
- LOG.warn("Reused local history {}", historyId);
+ LOG.warn("{}: Reused local history {}", shardName, historyId);
- LOG.debug("Created local history {}", historyId);
+ LOG.debug("{}: Created local history {}", shardName, historyId);
final FrontendHistoryMetadataBuilder builder = currentHistories.get(historyId);
if (builder != null) {
builder.onHistoryClosed();
final FrontendHistoryMetadataBuilder builder = currentHistories.get(historyId);
if (builder != null) {
builder.onHistoryClosed();
- LOG.debug("Closed history {}", historyId);
+ LOG.debug("{}: Closed history {}", shardName, historyId);
- LOG.warn("Closed unknown history {}, ignoring", historyId);
+ LOG.warn("{}: Closed unknown history {}, ignoring", shardName, historyId);
}
}
void onHistoryPurged(final LocalHistoryIdentifier historyId) {
final FrontendHistoryMetadataBuilder history = currentHistories.remove(historyId);
if (history == null) {
}
}
void onHistoryPurged(final LocalHistoryIdentifier historyId) {
final FrontendHistoryMetadataBuilder history = currentHistories.remove(historyId);
if (history == null) {
- LOG.warn("Purging unknown history {}", historyId);
+ LOG.warn("{}: Purging unknown history {}", shardName, historyId);
}
// XXX: do we need to account for cookies?
purgedHistories.add(Range.singleton(UnsignedLong.fromLongBits(historyId.getHistoryId())));
}
// XXX: do we need to account for cookies?
purgedHistories.add(Range.singleton(UnsignedLong.fromLongBits(historyId.getHistoryId())));
- LOG.debug("Purged history {}", historyId);
+ LOG.debug("{}: Purged history {}", historyId);
}
void onTransactionAborted(final TransactionIdentifier txId) {
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionAborted(txId);
}
void onTransactionAborted(final TransactionIdentifier txId) {
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionAborted(txId);
- LOG.debug("Committed transaction {}", txId);
+ LOG.debug("{}: Committed transaction {}", shardName, txId);
- LOG.warn("Unknown history for aborted transaction {}, ignoring", txId);
+ LOG.warn("{}: Unknown history for aborted transaction {}, ignoring", shardName, txId);
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionCommitted(txId);
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionCommitted(txId);
- LOG.debug("Aborted transaction {}", txId);
+ LOG.debug("{}: Aborted transaction {}", txId);
- LOG.warn("Unknown history for commited transaction {}, ignoring", txId);
+ LOG.warn("{}: Unknown history for commited transaction {}, ignoring", shardName, txId);
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionPurged(txId);
final FrontendHistoryMetadataBuilder history = getHistory(txId);
if (history != null) {
history.onTransactionPurged(txId);
- LOG.debug("Purged transaction {}", txId);
+ LOG.debug("{}: Purged transaction {}", txId);
- LOG.warn("Unknown history for purged transaction {}, ignoring", txId);
+ LOG.warn("{}: Unknown history for purged transaction {}, ignoring", shardName, txId);
for (FrontendClientMetadata m : snapshot.getClients()) {
LOG.debug("{}: applying metadata {}", shardName, m);
for (FrontendClientMetadata m : snapshot.getClients()) {
LOG.debug("{}: applying metadata {}", shardName, m);
- final FrontendClientMetadataBuilder b = new FrontendClientMetadataBuilder(m);
+ final FrontendClientMetadataBuilder b = new FrontendClientMetadataBuilder(shardName, m);
final FrontendIdentifier client = m.getIdentifier().getFrontendId();
LOG.debug("{}: client {} updated to {}", shardName, client, b);
final FrontendIdentifier client = m.getIdentifier().getFrontendId();
LOG.debug("{}: client {} updated to {}", shardName, client, b);
- final FrontendClientMetadataBuilder client = new FrontendClientMetadataBuilder(id);
+ final FrontendClientMetadataBuilder client = new FrontendClientMetadataBuilder(shardName, id);
final FrontendClientMetadataBuilder previous = clients.put(id.getFrontendId(), client);
if (previous != null) {
LOG.debug("{}: Replaced client {} with {}", shardName, previous, client);
final FrontendClientMetadataBuilder previous = clients.put(id.getFrontendId(), client);
if (previous != null) {
LOG.debug("{}: Replaced client {} with {}", shardName, previous, client);