Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bela 2356 #1352

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4503b3f
Merge remote branch 'remotes/upstream/master'
belaban Mar 3, 2011
062c7b0
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban Mar 16, 2012
14e30c9
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban Mar 22, 2012
67f2bcb
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban Mar 22, 2012
19a7edb
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban Apr 19, 2012
94fbe41
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban Apr 25, 2012
d2667fe
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban May 2, 2012
bff708e
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban Sep 21, 2012
7351efc
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban Sep 24, 2012
e0e8b85
ISPN-2339 Upgrade to JGroups 3.2.0.Alpha2
Sep 25, 2012
d34190c
ISPN-2343 Exception thrown to user from xsite ROC when failurePolicy …
Sep 26, 2012
8a7e3aa
ISPN-2319 Add ability to take a site offline into x-site implementation
Sep 27, 2012
e1b5e21
- Catching exception in GUI demo (otherwise the hourglass icon doesn'…
belaban Sep 28, 2012
384429d
Merge branch 'master' of github.com:belaban/infinispan
belaban Sep 28, 2012
c3015c5
ISPN-2339 Upgrade to JGroups 3.2.0.Alpha2
Sep 25, 2012
d98eedd
ISPN-2343 Exception thrown to user from xsite ROC when failurePolicy …
Sep 26, 2012
a040137
ISPN-2319 Add ability to take a site offline into x-site implementation
Sep 27, 2012
5f54fd5
- Catching exception in GUI demo (otherwise the hourglass icon doesn'…
belaban Sep 28, 2012
97ff246
Merge branch 'master' of github.com:belaban/infinispan
belaban Sep 28, 2012
503f2d7
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban Sep 28, 2012
daa944b
Merge branch 'master' of git://github.com/infinispan/infinispan
belaban Sep 28, 2012
e498b0a
Pulled upstream/master --> master
belaban Sep 28, 2012
75fe3ca
- Catching exception in InfinispanDemo
belaban Sep 29, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,6 +21,9 @@

import org.infinispan.remoting.RpcException;

import java.util.HashMap;
import java.util.Map;

/**
* Exception to be used to signal failures to backup to remote sites.
*
Expand All @@ -29,23 +32,40 @@
*/
public class BackupFailureException extends RpcException {

private String remoteSiteName;
private String localCacheName;
private Map<String,Throwable> failures;
private String localCacheName;


public BackupFailureException(Throwable cause, String remoteSiteName, String localCacheName) {
super("The local cache" + localCacheName + " failed to backup data to the remote site " + remoteSiteName, cause);
this.remoteSiteName = remoteSiteName;
this.localCacheName = localCacheName;
public BackupFailureException(String localCacheName) {
this.localCacheName = localCacheName;
}

public BackupFailureException() {
}

public String getRemoteSiteName() {
return remoteSiteName;
public void addFailure(String site, Throwable t) {
if(site != null && t != null) {
if(failures == null)
failures = new HashMap<String,Throwable>(3);
failures.put(site, t);
}
}

public String getRemoteSiteNames() {
return failures != null? failures.keySet().toString() : null;
}

public String getLocalCacheName() {
return localCacheName;
}

@Override
public String toString() {
if(failures == null || failures.isEmpty())
return super.toString();
StringBuilder sb=new StringBuilder("The local cache " + localCacheName + " failed to backup data to the remote sites:\n");
for(Map.Entry<String,Throwable> entry: failures.entrySet())
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
return sb.toString();
}
}
Expand Up @@ -126,6 +126,7 @@ public void processResponses(BackupResponse backupResponse, VisitableCommand com
backupResponse.waitForBackupToFinish();
SitesConfiguration sitesConfiguration = config.sites();
Map<String, Exception> failures = backupResponse.getFailedBackups();
BackupFailureException backupException = null;
for (Map.Entry<String, Exception> failure : failures.entrySet()) {
BackupFailurePolicy policy = sitesConfiguration.getFailurePolicy(failure.getKey());
if (policy == BackupFailurePolicy.CUSTOM) {
Expand All @@ -135,9 +136,13 @@ public void processResponses(BackupResponse backupResponse, VisitableCommand com
if (policy == BackupFailurePolicy.WARN) {
log.warnXsiteBackupFailed(cacheName, failure.getKey(), failure.getValue());
} else if (policy == BackupFailurePolicy.FAIL) {
throw new BackupFailureException(failure.getValue(),failure.getKey(), cacheName);
if(backupException == null)
backupException = new BackupFailureException(cacheName);
backupException.addFailure(failure.getKey(), failure.getValue());
}
}
if(backupException != null)
throw backupException;
}

@Override
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/infinispan/xsite/XSiteBackup.java
Expand Up @@ -46,4 +46,8 @@ public boolean isSync() {
public long getTimeout() {
return timeout;
}

public String toString() {
return siteName + " (" + (sync? "sync" : "async") + ", timeout=" + timeout + ")";
}
}
25 changes: 16 additions & 9 deletions demos/gui/src/main/java/org/infinispan/demo/InfinispanDemo.java
Expand Up @@ -167,15 +167,22 @@ public void actionPerformed(ActionEvent e) {
@Override
public void run() {
// based on the value of the radio button:
if (putEntryRadioButton.isSelected()) {
cache.put(keyTextField.getText(), valueTextField.getText(), lifespan(), TimeUnit.MILLISECONDS, maxIdle(), TimeUnit.MILLISECONDS);
} else if (removeEntryRadioButton.isSelected()) {
cache.remove(keyTextField.getText());
} else if (getEntryRadioButton.isSelected()) {
cache.get(keyTextField.getText());
try {
if (putEntryRadioButton.isSelected()) {
cache.put(keyTextField.getText(), valueTextField.getText(), lifespan(), TimeUnit.MILLISECONDS, maxIdle(), TimeUnit.MILLISECONDS);
} else if (removeEntryRadioButton.isSelected()) {
cache.remove(keyTextField.getText());
} else if (getEntryRadioButton.isSelected()) {
cache.get(keyTextField.getText());
}
}
catch(Throwable t) {
// log.error("failed to update cache", t);
}
finally {
dataViewTab.repaint();
processAction(goButton, false);
}
dataViewTab.repaint();
processAction(goButton, false);

// reset these values
lifespanSpinner.setValue(cache.getCacheConfiguration().expiration().lifespan());
Expand Down Expand Up @@ -379,7 +386,7 @@ public void run() {
Util.close(stream);
}
}
cache = cacheManager.getCache();
cache = cacheManager.getCache();
cache.start();

// repaint the cfg file display
Expand Down