forked from hazelcast/hazelcast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: hazelcast-documentation/src/JCache.md
- Loading branch information
Showing
12 changed files
with
595 additions
and
89 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
hazelcast/src/main/java/com/hazelcast/cache/BackupAwareEntryProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hazelcast.cache; | ||
|
||
import javax.cache.processor.EntryProcessor; | ||
|
||
/** | ||
* An invocable function that allows applications to perform compound operations | ||
* on a {@link javax.cache.Cache.Entry} atomically, according the defined | ||
* consistency of a {@link javax.cache.Cache}. | ||
* <p> | ||
* In difference to the normal {@link javax.cache.processor.EntryProcessor} | ||
* implementations where a backup is done using sending the complete changed resulting | ||
* object to the backup-partition, implementations of this sub-interface can create | ||
* an additional {@link javax.cache.processor.EntryProcessor} instances that are send | ||
* to the backup-partitions to apply logic which is either different from the owner | ||
* partition (e.g. not sending emails) or in the simple case similar to the main | ||
* operations. In the later case {@link #createBackupEntryProcessor()} can also return | ||
* <pre>this</pre>. | ||
* | ||
* @param <K> the type of keys maintained by this cache | ||
* @param <V> the type of cached values | ||
* @param <T> the type of the return value | ||
* @see javax.cache.processor.EntryProcessor | ||
* @since 3.4 | ||
*/ | ||
public interface BackupAwareEntryProcessor<K, V, T> | ||
extends EntryProcessor<K, V, T> { | ||
|
||
/** | ||
* Either creates a new, specialized {@link javax.cache.processor.EntryProcessor} | ||
* to be executed on the backup-partition or returns <pre>this</pre> to execute | ||
* the same processor remotely. | ||
* <p> | ||
* If null is returned the value is backed up using the normal value backup | ||
* mechanism, non exception is thrown and the update is applied as expected. | ||
* | ||
* @return the backup-partition EntryProcessor | ||
*/ | ||
EntryProcessor<K, V, T> createBackupEntryProcessor(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
* </pre> | ||
* </p> | ||
* | ||
* @since 3.3.1 | ||
*/ | ||
public interface CacheStatistics { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
.../src/main/java/com/hazelcast/cache/impl/operation/CacheBackupEntryProcessorOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hazelcast.cache.impl.operation; | ||
|
||
import com.hazelcast.cache.impl.CacheDataSerializerHook; | ||
import com.hazelcast.nio.ObjectDataInput; | ||
import com.hazelcast.nio.ObjectDataOutput; | ||
import com.hazelcast.nio.serialization.Data; | ||
import com.hazelcast.nio.serialization.IdentifiedDataSerializable; | ||
import com.hazelcast.spi.BackupOperation; | ||
|
||
import javax.cache.processor.EntryProcessor; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Operation of the Cache Backup Entry Processor. | ||
* <p>{@link com.hazelcast.cache.BackupAwareEntryProcessor} is executed on the partition. | ||
* Executing this method applies a backup entry processor to the requested | ||
* {@link com.hazelcast.cache.impl.ICacheRecordStore} which provides the required | ||
* functionality to apply the backup using the given {@link javax.cache.processor.EntryProcessor}.</p> | ||
*/ | ||
public class CacheBackupEntryProcessorOperation | ||
extends AbstractCacheOperation | ||
implements BackupOperation, IdentifiedDataSerializable { | ||
|
||
private EntryProcessor entryProcessor; | ||
private Object[] arguments; | ||
|
||
public CacheBackupEntryProcessorOperation() { | ||
} | ||
|
||
public CacheBackupEntryProcessorOperation(String name, Data key, EntryProcessor entryProcessor, | ||
Object... arguments) { | ||
super(name, key); | ||
this.entryProcessor = entryProcessor; | ||
this.arguments = arguments; | ||
} | ||
|
||
@Override | ||
public int getId() { | ||
return CacheDataSerializerHook.BACKUP_ENTRY_PROCESSOR; | ||
} | ||
|
||
@Override | ||
public void run() | ||
throws Exception { | ||
cache.invoke(key, entryProcessor, arguments); | ||
} | ||
|
||
@Override | ||
protected void writeInternal(ObjectDataOutput out) | ||
throws IOException { | ||
super.writeInternal(out); | ||
out.writeObject(entryProcessor); | ||
out.writeBoolean(arguments != null); | ||
if (arguments != null) { | ||
out.writeInt(arguments.length); | ||
for (Object arg : arguments) { | ||
out.writeObject(arg); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected void readInternal(ObjectDataInput in) | ||
throws IOException { | ||
super.readInternal(in); | ||
entryProcessor = in.readObject(); | ||
final boolean hasArguments = in.readBoolean(); | ||
if (hasArguments) { | ||
final int size = in.readInt(); | ||
arguments = new Object[size]; | ||
for (int i = 0; i < size; i++) { | ||
arguments[i] = in.readObject(); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.