[jboss-cvs] JBossAS SVN: r97832 - in trunk: system/src/main/java/org/jboss/system/server/profileservice/repository/clustered/local/file and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 15 00:47:12 EST 2009
Author: bstansberry at jboss.com
Date: 2009-12-15 00:47:11 -0500 (Tue, 15 Dec 2009)
New Revision: 97832
Modified:
trunk/cluster/src/main/java/org/jboss/profileservice/cluster/repository/DefaultRepositoryClusteringHandler.java
trunk/system/src/main/java/org/jboss/system/server/profileservice/repository/clustered/local/file/AbstractFileWriteAction.java
trunk/system/src/main/java/org/jboss/system/server/profileservice/repository/clustered/sync/AbstractSynchronizationAction.java
Log:
[JBAS-7102] Send last file chunk async as well; remote nodes communicate errors back via prepare
Modified: trunk/cluster/src/main/java/org/jboss/profileservice/cluster/repository/DefaultRepositoryClusteringHandler.java
===================================================================
--- trunk/cluster/src/main/java/org/jboss/profileservice/cluster/repository/DefaultRepositoryClusteringHandler.java 2009-12-15 05:45:19 UTC (rev 97831)
+++ trunk/cluster/src/main/java/org/jboss/profileservice/cluster/repository/DefaultRepositoryClusteringHandler.java 2009-12-15 05:47:11 UTC (rev 97832)
@@ -785,25 +785,9 @@
ByteChunk chunk = action.getNextBytes();
Object[] args = new Object[]{ id, action.getRepositoryContentModification().getItem(), chunk};
- if (chunk.getByteCount() > -1)
- {
- this.partition.callAsynchMethodOnCluster(getServiceHAName(), "pushBytes", args, PUSH_BYTES_TYPES, true);
- }
- else
- {
- List<?> rsps = this.partition.callMethodOnCluster(getServiceHAName(), "pushBytes", args, PUSH_BYTES_TYPES, true);
- for (Object rsp : rsps)
- {
- if (rsp instanceof NotSynchronizedException)
- {
- continue;
- }
- else if (rsp instanceof Throwable)
- {
- rethrowAsException((Throwable) rsp);
- }
- }
- }
+ // JBAS-7102 -- send chunks async; if there is a problem applying we'll
+ // fail in the prepare phase
+ this.partition.callAsynchMethodOnCluster(getServiceHAName(), "pushBytes", args, PUSH_BYTES_TYPES, true);
lastRead = chunk.getByteCount();
}
catch (Exception e)
Modified: trunk/system/src/main/java/org/jboss/system/server/profileservice/repository/clustered/local/file/AbstractFileWriteAction.java
===================================================================
--- trunk/system/src/main/java/org/jboss/system/server/profileservice/repository/clustered/local/file/AbstractFileWriteAction.java 2009-12-15 05:45:19 UTC (rev 97831)
+++ trunk/system/src/main/java/org/jboss/system/server/profileservice/repository/clustered/local/file/AbstractFileWriteAction.java 2009-12-15 05:47:11 UTC (rev 97832)
@@ -43,7 +43,7 @@
private File tempFile;
private OutputStream stream;
-
+
/**
* Create a new FileWriteAction.
*
@@ -61,16 +61,34 @@
protected void writeBytes(ByteChunk bytes) throws IOException
{
- if (bytes == null)
+ // This may be called asynchronously, so exceptions we throw
+ // may not propagate back to the caller. So, log them and mark
+ // ourself as rollback only to ensure the overall synchronization
+ // fails
+ try
{
- throw new IllegalArgumentException("Null bytes");
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("Null bytes");
+ }
+ if (bytes.getByteCount() < 0)
+ {
+ throw new IllegalArgumentException("Illegal byte count " + bytes.getByteCount());
+ }
+
+ OutputStream os = getOutputStream();
+ os.write(bytes.getBytes(), 0, bytes.getByteCount());
}
- if (bytes.getByteCount() < 0)
+ catch (IOException e)
{
- throw new IllegalArgumentException("Illegal byte count " + bytes.getByteCount());
+ setRollbackOnly();
+ throw e;
}
- OutputStream os = getOutputStream();
- os.write(bytes.getBytes(), 0, bytes.getByteCount());
+ catch (RuntimeException e)
+ {
+ setRollbackOnly();
+ throw e;
+ }
}
@Override
Modified: trunk/system/src/main/java/org/jboss/system/server/profileservice/repository/clustered/sync/AbstractSynchronizationAction.java
===================================================================
--- trunk/system/src/main/java/org/jboss/system/server/profileservice/repository/clustered/sync/AbstractSynchronizationAction.java 2009-12-15 05:45:19 UTC (rev 97831)
+++ trunk/system/src/main/java/org/jboss/system/server/profileservice/repository/clustered/sync/AbstractSynchronizationAction.java 2009-12-15 05:47:11 UTC (rev 97832)
@@ -220,6 +220,21 @@
protected abstract void doRollbackFromComplete();
protected abstract void doRollbackFromPrepared();
+ /**
+ * Sets the state of this action to @{link {@link State#ROLLBACK_ONLY} unless
+ * the state is already prepared, committed or rolled back, in which case
+ * it does nothing.
+ */
+ protected void setRollbackOnly()
+ {
+
+ if (this.state != State.PREPARED && this.state != State.COMMITTED
+ && this.state != State.ROLLEDBACK)
+ {
+ this.state = State.ROLLBACK_ONLY;
+ }
+ }
+
protected static RepositoryItemMetadata getMarkedRemovedItem(ContentModification base)
{
RepositoryItemMetadata result = base.getItem();
More information about the jboss-cvs-commits
mailing list