mirror of https://github.com/apache/activemq.git
group moving from trunk to the sandbox
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@685632 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
368cb6653e
commit
17034f2b04
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Return information about map update
|
||||
*
|
||||
*/
|
||||
public class AsyncMapRequest implements RequestCallback{
|
||||
private final Object mutex = new Object();
|
||||
|
||||
private Set<String> requests = new HashSet<String>();
|
||||
|
||||
public void add(String id, MapRequest request) {
|
||||
request.setCallback(this);
|
||||
this.requests.add(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for requests
|
||||
* @param timeout
|
||||
* @return
|
||||
*/
|
||||
public boolean isSuccess(long timeout) {
|
||||
long deadline = System.currentTimeMillis() + timeout;
|
||||
while (!this.requests.isEmpty()) {
|
||||
synchronized (this.mutex) {
|
||||
try {
|
||||
this.mutex.wait(timeout);
|
||||
} catch (InterruptedException e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
timeout = Math.max(deadline - System.currentTimeMillis(), 0);
|
||||
}
|
||||
return this.requests.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
public void finished(String id) {
|
||||
this.requests.remove(id);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
/**
|
||||
* Default implementation of a MapChangedListener
|
||||
*
|
||||
*/
|
||||
public class DefaultMapChangedListener implements MapChangedListener{
|
||||
|
||||
public void mapInsert(Member owner, Object key, Object value) {
|
||||
}
|
||||
|
||||
public void mapRemove(Member owner, Object key, Object value,boolean expired) {
|
||||
}
|
||||
|
||||
public void mapUpdate(Member owner, Object key, Object oldValue,Object newValue) {
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
|
||||
/**
|
||||
* Used to pass information around
|
||||
*
|
||||
*/
|
||||
public class ElectionMessage implements Externalizable{
|
||||
static enum MessageType{ELECTION,ANSWER,COORDINATOR};
|
||||
private Member member;
|
||||
private MessageType type;
|
||||
|
||||
/**
|
||||
* @return the member
|
||||
*/
|
||||
public Member getMember() {
|
||||
return this.member;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param member the member to set
|
||||
*/
|
||||
public void setMember(Member member) {
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public MessageType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type the type to set
|
||||
*/
|
||||
public void setType(MessageType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if election message
|
||||
*/
|
||||
public boolean isElection() {
|
||||
return this.type != null && this.type.equals(MessageType.ELECTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if answer message
|
||||
*/
|
||||
public boolean isAnswer() {
|
||||
return this.type != null && this.type.equals(MessageType.ANSWER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if coordinator message
|
||||
*/
|
||||
public boolean isCoordinator() {
|
||||
return this.type != null && this.type.equals(MessageType.COORDINATOR);
|
||||
}
|
||||
|
||||
|
||||
public ElectionMessage copy() {
|
||||
ElectionMessage result = new ElectionMessage();
|
||||
result.member=this.member;
|
||||
result.type=this.type;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public void readExternal(ObjectInput in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
this.member=(Member) in.readObject();
|
||||
this.type=(MessageType) in.readObject();
|
||||
}
|
||||
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeObject(this.member);
|
||||
out.writeObject(this.type);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ElectionMessage: "+ this.member + "{"+this.type+ "}";
|
||||
}
|
||||
}
|
|
@ -1,210 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
|
||||
/**
|
||||
* Holds information about an EntryKey
|
||||
*
|
||||
*/
|
||||
class EntryKey<K> implements Externalizable {
|
||||
private Member owner;
|
||||
private K key;
|
||||
private boolean locked;
|
||||
private boolean removeOnExit;
|
||||
private boolean releaseLockOnExit;
|
||||
private long expiration;
|
||||
private long lockExpiration;
|
||||
|
||||
/**
|
||||
* Default constructor - for serialization
|
||||
*/
|
||||
public EntryKey() {
|
||||
}
|
||||
|
||||
EntryKey(Member owner, K key) {
|
||||
this.owner = owner;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.key != null ? this.key.hashCode() : super.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the owner
|
||||
*/
|
||||
public Member getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
|
||||
public void setOwner(Member member) {
|
||||
this.owner=member;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public K getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the share
|
||||
*/
|
||||
public boolean isLocked() {
|
||||
return this.locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param share the share to set
|
||||
*/
|
||||
public void setLocked(boolean locked) {
|
||||
this.locked = locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the removeOnExit
|
||||
*/
|
||||
public boolean isRemoveOnExit() {
|
||||
return this.removeOnExit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param removeOnExit
|
||||
* the removeOnExit to set
|
||||
*/
|
||||
public void setRemoveOnExit(boolean removeOnExit) {
|
||||
this.removeOnExit = removeOnExit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the expiration
|
||||
*/
|
||||
public long getExpiration() {
|
||||
return expiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param expiration the expiration to set
|
||||
*/
|
||||
public void setExpiration(long expiration) {
|
||||
this.expiration = expiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lockExpiration
|
||||
*/
|
||||
public long getLockExpiration() {
|
||||
return lockExpiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lockExpiration the lockExpiration to set
|
||||
*/
|
||||
public void setLockExpiration(long lockExpiration) {
|
||||
this.lockExpiration = lockExpiration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the releaseLockOnExit
|
||||
*/
|
||||
public boolean isReleaseLockOnExit() {
|
||||
return releaseLockOnExit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param releaseLockOnExit the releaseLockOnExit to set
|
||||
*/
|
||||
public void setReleaseLockOnExit(boolean releaseLockOnExit) {
|
||||
this.releaseLockOnExit = releaseLockOnExit;
|
||||
}
|
||||
|
||||
void setTimeToLive(long ttl) {
|
||||
if (ttl > 0 ) {
|
||||
this.expiration=ttl+System.currentTimeMillis();
|
||||
}else {
|
||||
this.expiration =0l;
|
||||
}
|
||||
}
|
||||
|
||||
void setLockTimeToLive(long ttl) {
|
||||
if(ttl > 0) {
|
||||
this.lockExpiration=ttl+System.currentTimeMillis();
|
||||
}else {
|
||||
this.lockExpiration=0l;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isExpired() {
|
||||
return isExpired(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
boolean isExpired(long currentTime) {
|
||||
return this.expiration > 0 && this.expiration < currentTime;
|
||||
}
|
||||
|
||||
boolean isLockExpired() {
|
||||
return isLockExpired(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
boolean isLockExpired(long currentTime) {
|
||||
return this.lockExpiration > 0 && this.lockExpiration < currentTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
boolean result = false;
|
||||
if (obj instanceof EntryKey) {
|
||||
EntryKey other = (EntryKey) obj;
|
||||
result = other.key.equals(this.key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeObject(this.owner);
|
||||
out.writeObject(this.key);
|
||||
out.writeBoolean(isLocked());
|
||||
out.writeBoolean(isRemoveOnExit());
|
||||
out.writeBoolean(isReleaseLockOnExit());
|
||||
out.writeLong(getExpiration());
|
||||
out.writeLong(getLockExpiration());
|
||||
}
|
||||
|
||||
public void readExternal(ObjectInput in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
this.owner = (Member) in.readObject();
|
||||
this.key = (K) in.readObject();
|
||||
this.locked = in.readBoolean();
|
||||
this.removeOnExit=in.readBoolean();
|
||||
this.releaseLockOnExit=in.readBoolean();
|
||||
this.expiration=in.readLong();
|
||||
this.lockExpiration=in.readLong();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "key:"+this.key;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,204 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
|
||||
/**
|
||||
* Used to pass information around
|
||||
*
|
||||
*/
|
||||
public class EntryMessage implements Externalizable{
|
||||
static enum MessageType{INSERT,DELETE,SYNC};
|
||||
private EntryKey key;
|
||||
private Object value;
|
||||
private Object oldValue;
|
||||
private MessageType type;
|
||||
private boolean mapUpdate;
|
||||
private boolean expired;
|
||||
private boolean lockExpired;
|
||||
private boolean lockUpdate;
|
||||
|
||||
/**
|
||||
* @return the owner
|
||||
*/
|
||||
public EntryKey getKey() {
|
||||
return this.key;
|
||||
}
|
||||
/**
|
||||
* @param key
|
||||
*/
|
||||
public void setKey(EntryKey key) {
|
||||
this.key = key;
|
||||
}
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public Object getValue() {
|
||||
return this.value;
|
||||
}
|
||||
/**
|
||||
* @param value the value to set
|
||||
*/
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the oldValue
|
||||
*/
|
||||
public Object getOldValue() {
|
||||
return this.oldValue;
|
||||
}
|
||||
/**
|
||||
* @param oldValue the oldValue to set
|
||||
*/
|
||||
public void setOldValue(Object oldValue) {
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public MessageType getType() {
|
||||
return this.type;
|
||||
}
|
||||
/**
|
||||
* @param type the type to set
|
||||
*/
|
||||
public void setType(MessageType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mapUpdate
|
||||
*/
|
||||
public boolean isMapUpdate() {
|
||||
return this.mapUpdate;
|
||||
}
|
||||
/**
|
||||
* @param mapUpdate the mapUpdate to set
|
||||
*/
|
||||
public void setMapUpdate(boolean mapUpdate) {
|
||||
this.mapUpdate = mapUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the expired
|
||||
*/
|
||||
public boolean isExpired() {
|
||||
return expired;
|
||||
}
|
||||
/**
|
||||
* @param expired the expired to set
|
||||
*/
|
||||
public void setExpired(boolean expired) {
|
||||
this.expired = expired;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lockExpired
|
||||
*/
|
||||
public boolean isLockExpired() {
|
||||
return lockExpired;
|
||||
}
|
||||
/**
|
||||
* @param lockExpired the lockExpired to set
|
||||
*/
|
||||
public void setLockExpired(boolean lockExpired) {
|
||||
this.lockExpired = lockExpired;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lockUpdate
|
||||
*/
|
||||
public boolean isLockUpdate() {
|
||||
return lockUpdate;
|
||||
}
|
||||
/**
|
||||
* @param lockUpdate the lockUpdate to set
|
||||
*/
|
||||
public void setLockUpdate(boolean lockUpdate) {
|
||||
this.lockUpdate = lockUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return if insert message
|
||||
*/
|
||||
public boolean isInsert() {
|
||||
return this.type != null && this.type.equals(MessageType.INSERT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if delete message
|
||||
*/
|
||||
public boolean isDelete() {
|
||||
return this.type != null && this.type.equals(MessageType.DELETE);
|
||||
}
|
||||
|
||||
public boolean isSync() {
|
||||
return this.type != null && this.type.equals(MessageType.SYNC);
|
||||
}
|
||||
|
||||
|
||||
public EntryMessage copy() {
|
||||
EntryMessage result = new EntryMessage();
|
||||
result.key=this.key;
|
||||
result.value=this.value;
|
||||
result.oldValue=this.oldValue;
|
||||
result.type=this.type;
|
||||
result.mapUpdate=this.mapUpdate;
|
||||
result.expired=this.expired;
|
||||
result.lockExpired=this.lockExpired;
|
||||
result.lockUpdate=this.lockUpdate;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void readExternal(ObjectInput in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
this.key=(EntryKey) in.readObject();
|
||||
this.value=in.readObject();
|
||||
this.oldValue=in.readObject();
|
||||
this.type=(MessageType) in.readObject();
|
||||
this.mapUpdate=in.readBoolean();
|
||||
this.expired=in.readBoolean();
|
||||
this.lockExpired=in.readBoolean();
|
||||
this.lockUpdate=in.readBoolean();
|
||||
}
|
||||
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeObject(this.key);
|
||||
out.writeObject(this.value);
|
||||
out.writeObject(this.oldValue);
|
||||
out.writeObject(this.type);
|
||||
out.writeBoolean(this.mapUpdate);
|
||||
out.writeBoolean(this.expired);
|
||||
out.writeBoolean(this.lockExpired);
|
||||
out.writeBoolean(this.lockUpdate);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "EntryMessage: "+this.type + "[" + this.key + "," + this.value +
|
||||
"]{update=" + this.mapUpdate + "}";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 VIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.group;
|
||||
|
||||
|
||||
/**
|
||||
* Holds information about the Value in the Map
|
||||
*
|
||||
*/
|
||||
class EntryValue<V> {
|
||||
private EntryKey key;
|
||||
private V value;
|
||||
|
||||
|
||||
EntryValue(EntryKey key, V value){
|
||||
this.key=key;
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the owner
|
||||
*/
|
||||
public EntryKey getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public V getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the value
|
||||
* @param value
|
||||
*/
|
||||
public void setValue(V value) {
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.value != null ? this.value.hashCode() : super.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
boolean result = false;
|
||||
if (obj instanceof EntryValue) {
|
||||
EntryValue other = (EntryValue)obj;
|
||||
result = (this.value==null && other.value==null) ||
|
||||
(this.value != null && other.value != null && this.value.equals(other.value));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,32 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
/**
|
||||
* thrown when updating a key to map that the local client doesn't own
|
||||
*
|
||||
*/
|
||||
public class GroupMapUpdateException extends RuntimeException {
|
||||
private static final long serialVersionUID = -7584658017201604560L;
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public GroupMapUpdateException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
|
||||
/**
|
||||
* A listener for message communication
|
||||
*
|
||||
*/
|
||||
public interface GroupMessageListener {
|
||||
|
||||
/**
|
||||
* Called when a message is delivered to the <CODE>Group</CODE> from another member
|
||||
* @param sender the member who sent the message
|
||||
* @param replyId the id to use to respond to a message
|
||||
* @param message the message object
|
||||
*/
|
||||
void messageDelivered(Member sender, String replyId, Object message);
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
/**
|
||||
*Get notifications about changes to the state of the map
|
||||
*
|
||||
*/
|
||||
public interface MapChangedListener {
|
||||
|
||||
/**
|
||||
* Called when a key/value pair is inserted into the map
|
||||
* @param owner
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
void mapInsert(Member owner,Object key, Object value);
|
||||
|
||||
/**
|
||||
* Called when a key value is updated in the map
|
||||
* @param owner
|
||||
* @param Key
|
||||
* @param oldValue
|
||||
* @param newValue
|
||||
*/
|
||||
void mapUpdate(Member owner,Object Key,Object oldValue,Object newValue);
|
||||
|
||||
/**
|
||||
* Called when a key value is removed from the map
|
||||
* @param owner
|
||||
* @param key
|
||||
* @param value
|
||||
* @param expired
|
||||
*/
|
||||
void mapRemove(Member owner,Object key, Object value,boolean expired);
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Return information about map update
|
||||
*
|
||||
*/
|
||||
public class MapRequest {
|
||||
private final AtomicBoolean done = new AtomicBoolean();
|
||||
private Object response;
|
||||
private RequestCallback callback;
|
||||
|
||||
Object get(long timeout) {
|
||||
synchronized (this.done) {
|
||||
if (this.done.get() == false && this.response == null) {
|
||||
try {
|
||||
this.done.wait(timeout);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.response;
|
||||
}
|
||||
|
||||
void put(String id,Object response) {
|
||||
this.response = response;
|
||||
cancel();
|
||||
RequestCallback callback = this.callback;
|
||||
if (callback != null) {
|
||||
callback.finished(id);
|
||||
}
|
||||
}
|
||||
|
||||
void cancel() {
|
||||
this.done.set(true);
|
||||
synchronized (this.done) {
|
||||
this.done.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
void setCallback(RequestCallback callback) {
|
||||
this.callback=callback;
|
||||
}
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
import javax.jms.Destination;
|
||||
import org.apache.activemq.util.IdGenerator;
|
||||
import com.sun.jndi.url.corbaname.corbanameURLContextFactory;
|
||||
|
||||
/**
|
||||
*<P>
|
||||
* A <CODE>Member</CODE> holds information about a member of the group
|
||||
*
|
||||
*/
|
||||
public class Member implements Externalizable {
|
||||
private String name;
|
||||
private String id;
|
||||
private String hostname;
|
||||
private long startTime;
|
||||
private int coordinatorWeight;
|
||||
private Destination inBoxDestination;
|
||||
private transient long timeStamp;
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor - only used by serialization
|
||||
*/
|
||||
public Member() {
|
||||
}
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public Member(String name) {
|
||||
this.name = name;
|
||||
this.hostname = IdGenerator.getHostName();
|
||||
this.startTime=System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
void setId(String id) {
|
||||
this.id=id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hostname
|
||||
*/
|
||||
public String getHostname() {
|
||||
return this.hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the startTime
|
||||
*/
|
||||
public long getStartTime() {
|
||||
return this.startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the inbox destination
|
||||
*/
|
||||
public Destination getInBoxDestination() {
|
||||
return this.inBoxDestination;
|
||||
}
|
||||
|
||||
void setInBoxDestination(Destination dest) {
|
||||
this.inBoxDestination=dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the timeStamp
|
||||
*/
|
||||
long getTimeStamp() {
|
||||
return this.timeStamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param timeStamp the timeStamp to set
|
||||
*/
|
||||
void setTimeStamp(long timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
/**
|
||||
* @return the coordinatorWeight
|
||||
*/
|
||||
public int getCoordinatorWeight() {
|
||||
return this.coordinatorWeight;
|
||||
}
|
||||
/**
|
||||
* @param coordinatorWeight the coordinatorWeight to set
|
||||
*/
|
||||
public void setCoordinatorWeight(int coordinatorWeight) {
|
||||
this.coordinatorWeight = coordinatorWeight;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString() {
|
||||
return this.name+"["+this.id+"]@"+this.hostname;
|
||||
}
|
||||
|
||||
|
||||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
||||
this.coordinatorWeight=in.readInt();;
|
||||
this.name = in.readUTF();
|
||||
this.id = in.readUTF();
|
||||
this.hostname = in.readUTF();
|
||||
this.startTime=in.readLong();
|
||||
this.inBoxDestination=(Destination) in.readObject();
|
||||
}
|
||||
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeInt(this.coordinatorWeight);
|
||||
out.writeUTF(this.name != null ? this.name : "");
|
||||
out.writeUTF(this.id != null ? this.id : "");
|
||||
out.writeUTF(this.hostname != null ? this.hostname : "");
|
||||
out.writeLong(this.startTime);
|
||||
out.writeObject(this.inBoxDestination);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
boolean result = false;
|
||||
if (obj instanceof Member) {
|
||||
Member other = (Member)obj;
|
||||
result = this.id.equals(other.id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
/**
|
||||
* A listener for membership changes to a group
|
||||
*
|
||||
*/
|
||||
public interface MemberChangedListener {
|
||||
|
||||
/**
|
||||
* Notification a member has started
|
||||
* @param member
|
||||
*/
|
||||
void memberStarted(Member member);
|
||||
|
||||
/**
|
||||
* Notification a member has stopped
|
||||
* @param member
|
||||
*/
|
||||
void memberStopped(Member member);
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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 org.apache.activemq.group;
|
||||
|
||||
|
||||
/**
|
||||
* Return information about map update
|
||||
*
|
||||
*/
|
||||
public interface RequestCallback{
|
||||
/**
|
||||
* Optionally called when a request is finished
|
||||
* @param id
|
||||
*/
|
||||
void finished(String id);
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You 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.
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Shared state, messaging and membership information between members of a distributed group
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue