Browse Source

no need to pass sender, it is always owner of local node

tags/v0.4.0
Jonathan Cobb 5 years ago
parent
commit
7bc3af540b
10 changed files with 23 additions and 26 deletions
  1. +1
    -1
      bubble-server/src/main/java/bubble/notify/DelegatedNotificationHandlerBase.java
  2. +2
    -3
      bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java
  3. +1
    -2
      bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_to_sage.java
  4. +1
    -2
      bubble-server/src/main/java/bubble/notify/NotificationHandler_retrieve_backup.java
  5. +1
    -1
      bubble-server/src/main/java/bubble/resources/account/AuthResource.java
  6. +1
    -1
      bubble-server/src/main/java/bubble/service/backup/BackupService.java
  7. +1
    -1
      bubble-server/src/main/java/bubble/service/boot/SageHelloService.java
  8. +1
    -1
      bubble-server/src/main/java/bubble/service/boot/StandardSelfNodeService.java
  9. +1
    -1
      bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java
  10. +13
    -13
      bubble-server/src/main/java/bubble/service/notify/NotificationService.java

+ 1
- 1
bubble-server/src/main/java/bubble/notify/DelegatedNotificationHandlerBase.java View File

@@ -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);
}

}

+ 2
- 3
bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java View File

@@ -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<BubbleNode> 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++;
}


+ 1
- 2
bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_to_sage.java View File

@@ -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);
}
}
}

+ 1
- 2
bubble-server/src/main/java/bubble/notify/NotificationHandler_retrieve_backup.java View File

@@ -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);
}
}

+ 1
- 1
bubble-server/src/main/java/bubble/resources/account/AuthResource.java View File

@@ -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);
}


+ 1
- 1
bubble-server/src/main/java/bubble/service/backup/BackupService.java View File

@@ -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 {


+ 1
- 1
bubble-server/src/main/java/bubble/service/boot/SageHelloService.java View File

@@ -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);


+ 1
- 1
bubble-server/src/main/java/bubble/service/boot/StandardSelfNodeService.java View File

@@ -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 {


+ 1
- 1
bubble-server/src/main/java/bubble/service/cloud/StandardNetworkService.java View File

@@ -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());


+ 13
- 13
bubble-server/src/main/java/bubble/service/notify/NotificationService.java View File

@@ -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,


Loading…
Cancel
Save