diff --git a/bubble-server/src/main/java/bubble/notify/DelegatedNotificationHandlerBase.java b/bubble-server/src/main/java/bubble/notify/DelegatedNotificationHandlerBase.java index 78b7fc48..d3a109ad 100644 --- a/bubble-server/src/main/java/bubble/notify/DelegatedNotificationHandlerBase.java +++ b/bubble-server/src/main/java/bubble/notify/DelegatedNotificationHandlerBase.java @@ -20,7 +20,7 @@ public abstract class DelegatedNotificationHandlerBase extends ReceivedNotificat reply.setResponse(json(json(result), JsonNode.class)); } - notificationService.notify(configuration.getThisNode().getAccount(), sender, type, reply); + notificationService.notify(sender, type, reply); } } diff --git a/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java b/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java index ee8fe27e..56209718 100644 --- a/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java +++ b/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java @@ -40,7 +40,6 @@ public class NotificationHandler_hello_from_sage extends ReceivedNotificationHan // Upstream is telling us about our peers final BubbleNode payloadNode = n.getNode(); final BubbleNode thisNode = configuration.getThisNode(); - final String systemAccount = configuration.getThisNode().getAccount(); final List peers = payloadNode.getPeers(); int peerCount = 0; boolean foundSelf = false; @@ -60,12 +59,12 @@ public class NotificationHandler_hello_from_sage extends ReceivedNotificationHan if (found == null) { log.info("hello_from_sage: creating peer: "+json(peer)); nodeDAO.create(peer); - notificationService.notify(systemAccount, peer, peer_hello, thisNode); + notificationService.notify(peer, peer_hello, thisNode); } else { found.upstreamUpdate(peer); log.info("hello_from_sage: updating peer: "+json(peer)); nodeDAO.update(found); - notificationService.notify(systemAccount, found, peer_hello, thisNode); + notificationService.notify(found, peer_hello, thisNode); } peerCount++; } diff --git a/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_to_sage.java b/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_to_sage.java index 85ef9a30..211d9224 100644 --- a/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_to_sage.java +++ b/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_to_sage.java @@ -28,8 +28,7 @@ public class NotificationHandler_hello_to_sage extends ReceivedNotificationHandl log.info("hello_to_sage: returning peers: "+peers.stream().map(BubbleNode::getFqdn).collect(joining(", "))); node.setPeers(peers); - final String systemAccount = configuration.getThisNode().getAccount(); - notificationService.notify(systemAccount, node, hello_from_sage, node); + notificationService.notify(node, hello_from_sage, node); } } } diff --git a/bubble-server/src/main/java/bubble/notify/NotificationHandler_retrieve_backup.java b/bubble-server/src/main/java/bubble/notify/NotificationHandler_retrieve_backup.java index 28fcb711..bc599547 100644 --- a/bubble-server/src/main/java/bubble/notify/NotificationHandler_retrieve_backup.java +++ b/bubble-server/src/main/java/bubble/notify/NotificationHandler_retrieve_backup.java @@ -37,7 +37,6 @@ public class NotificationHandler_retrieve_backup extends ReceivedNotificationHan } payloadNode.setBackup(backup); - final String systemAccount = configuration.getThisNode().getAccount(); - notificationService.notify(systemAccount, node, backup_response, payloadNode); + notificationService.notify(node, backup_response, payloadNode); } } diff --git a/bubble-server/src/main/java/bubble/resources/account/AuthResource.java b/bubble-server/src/main/java/bubble/resources/account/AuthResource.java index cdc9e6ff..b110805e 100644 --- a/bubble-server/src/main/java/bubble/resources/account/AuthResource.java +++ b/bubble-server/src/main/java/bubble/resources/account/AuthResource.java @@ -147,7 +147,7 @@ public class AuthResource { } restoreService.registerRestore(restoreKey, keys); - final NotificationReceipt receipt = notificationService.notify(thisNode.getUuid(), sageNode, retrieve_backup, thisNode.setRestoreKey(getRestoreKey())); + final NotificationReceipt receipt = notificationService.notify(sageNode, retrieve_backup, thisNode.setRestoreKey(getRestoreKey())); return ok(receipt); } diff --git a/bubble-server/src/main/java/bubble/service/backup/BackupService.java b/bubble-server/src/main/java/bubble/service/backup/BackupService.java index ee751dc9..e080ec3c 100644 --- a/bubble-server/src/main/java/bubble/service/backup/BackupService.java +++ b/bubble-server/src/main/java/bubble/service/backup/BackupService.java @@ -206,7 +206,7 @@ public class BackupService extends SimpleDaemon { if (sageNode == null) { log.warn("backup: sage node not found, cannot notify"); } else { - final NotificationReceipt receipt = notificationService.notify(configuration.getThisNode().getUuid(), sageNode, register_backup, configuration.getThisNode()); + final NotificationReceipt receipt = notificationService.notify(sageNode, register_backup, configuration.getThisNode()); if (receipt.isSuccess()) { log.info("backup: sage node notified of backup"); } else { diff --git a/bubble-server/src/main/java/bubble/service/boot/SageHelloService.java b/bubble-server/src/main/java/bubble/service/boot/SageHelloService.java index d73486ff..61aed49b 100644 --- a/bubble-server/src/main/java/bubble/service/boot/SageHelloService.java +++ b/bubble-server/src/main/java/bubble/service/boot/SageHelloService.java @@ -59,7 +59,7 @@ public class SageHelloService extends SimpleDaemon { log.error("hello_to_sage: sage node not found: " + c.getSageNode()); } else { log.info("hello_to_sage: sending hello..."); - final NotificationReceipt receipt = notificationService.notify(selfNode.getUuid(), sage, hello_to_sage, selfNode); + final NotificationReceipt receipt = notificationService.notify(sage, hello_to_sage, selfNode); log.info("hello_to_sage: received reply from sage node: " + json(receipt, COMPACT_MAPPER)); if (receipt.isSuccess()) { if (!sageHelloSent.get()) sageHelloSent.set(true); diff --git a/bubble-server/src/main/java/bubble/service/boot/StandardSelfNodeService.java b/bubble-server/src/main/java/bubble/service/boot/StandardSelfNodeService.java index 4f19c799..fcfbd231 100644 --- a/bubble-server/src/main/java/bubble/service/boot/StandardSelfNodeService.java +++ b/bubble-server/src/main/java/bubble/service/boot/StandardSelfNodeService.java @@ -321,7 +321,7 @@ public class StandardSelfNodeService implements SelfNodeService { } log.debug("finalizeRestore: Notifying sage that restore is complete: " + getSageNode()); - final NotificationReceipt receipt = notificationService.notify(selfNode.getUuid(), sageNode, NotificationType.restore_complete, selfNode); + final NotificationReceipt receipt = notificationService.notify(sageNode, NotificationType.restore_complete, selfNode); if (!receipt.isSuccess()) { return die("finalizeRestore: sage notification failed: "+json(receipt, COMPACT_MAPPER)); } else { diff --git a/bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java b/bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java index b8831143..2af99558 100644 --- a/bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java +++ b/bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java @@ -475,7 +475,7 @@ public class StandardNetworkService implements NetworkService { final String prefix = "isReachable(" + node.id() + "): "; try { log.info(prefix+"starting"); - final NotificationReceipt receipt = notificationService.notify(node.getAccount(), node, NotificationType.health_check, null); + final NotificationReceipt receipt = notificationService.notify(node, NotificationType.health_check, null); if (receipt == null) { log.info(prefix+" health_check failed, checking via cloud"); final CloudService cloud = cloudDAO.findByUuid(node.getCloud()); diff --git a/bubble-server/src/main/java/bubble/service/notify/NotificationService.java b/bubble-server/src/main/java/bubble/service/notify/NotificationService.java index 571d6bec..4765f9b1 100644 --- a/bubble-server/src/main/java/bubble/service/notify/NotificationService.java +++ b/bubble-server/src/main/java/bubble/service/notify/NotificationService.java @@ -44,11 +44,11 @@ public class NotificationService { @Autowired private BubbleNodeKeyDAO nodeKeyDAO; @Autowired private NotificationReceiverService notificationReceiverService; - public NotificationReceipt notify(String sender, ApiClientBase api, NotificationType type, Object payload) { - return notify(sender, api, null, type, payload); + public NotificationReceipt notify(ApiClientBase api, NotificationType type, Object payload) { + return notify(api, null, type, payload); } - public NotificationReceipt notify(String sender, BubbleNode node, NotificationType type, Object payload) { + public NotificationReceipt notify(BubbleNode node, NotificationType type, Object payload) { if (nodeKeyDAO.findFirstByNode(node.getUuid()) == null) { log.warn("notify: no keys found for node: "+node.getUuid()); return null; @@ -57,27 +57,27 @@ public class NotificationService { ? node.getApiQuickClient(configuration) : node.getApiClient(configuration); final String toNodeUuid = node.getUuid(); - return notify(sender, api, toNodeUuid, type, payload); + return notify(api, toNodeUuid, type, payload); } - public NotificationReceipt notifyWithEnhancedReceipt(String sender, BubbleNode node, NotificationType type, Object payload) { + public NotificationReceipt notifyWithEnhancedReceipt(BubbleNode node, NotificationType type, Object payload) { final ApiClientBase api = node.getApiClient(configuration); final String toNodeUuid = node.getUuid(); - return notifyWithEnhancedReceipt(sender, api, toNodeUuid, type, payload); + return notifyWithEnhancedReceipt(api, toNodeUuid, type, payload); } - public NotificationReceipt notify(String sender, ApiClientBase api, String toNodeUuid, NotificationType type, Object payload) { - return _notify(sender, api, toNodeUuid, type, payload, false); + public NotificationReceipt notify(ApiClientBase api, String toNodeUuid, NotificationType type, Object payload) { + return _notify(api, toNodeUuid, type, payload, false); } - public NotificationReceipt notifyWithEnhancedReceipt(String sender, ApiClientBase api, String toNodeUuid, NotificationType type, Object payload) { - return _notify(sender, api, toNodeUuid, type, payload, true); + public NotificationReceipt notifyWithEnhancedReceipt(ApiClientBase api, String toNodeUuid, NotificationType type, Object payload) { + return _notify(api, toNodeUuid, type, payload, true); } - public NotificationReceipt _notify(String sender, ApiClientBase api, String toNodeUuid, NotificationType type, Object payload, boolean enhancedReceipt) { + public NotificationReceipt _notify(ApiClientBase api, String toNodeUuid, NotificationType type, Object payload, boolean enhancedReceipt) { final BubbleNode thisNode = configuration.getThisNode(); final boolean isLocal = toNodeUuid != null && toNodeUuid.equals(thisNode.getUuid()); final SentNotification notification = sentNotificationDAO.create((SentNotification) new SentNotification() .setNotificationId(getNotificationId(payload)) - .setAccount(sender) + .setAccount(thisNode.getAccount()) .setType(type) .setFromNode(thisNode.getUuid()) .setToNode(toNodeUuid != null ? toNodeUuid : api.getBaseUri()) @@ -157,7 +157,7 @@ public class NotificationService { // register callback for response log.debug("notifySync ("+notification.getClass().getSimpleName()+"/"+notification.getId()+"): sending notification: "+activeNotification.getId()); syncRequests.put(notification.getId(), notification); - final NotificationReceipt receipt = _notify(configuration.getThisNode().getAccount(), + final NotificationReceipt receipt = _notify( delegate.getApiClient(configuration), delegate.getUuid(), type,