Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With new listener, an event is published when a new migration process starts and another event when migration is completed. Those events include stats about migration process; start time, planned migration count, completed migration count etc. Additionally, on each replica migration, both for primary and backup replica migrations, a migration event is published. This event includes partition-id, replica-index and migration progress stats.
- Loading branch information
Showing
38 changed files
with
1,279 additions
and
571 deletions.
There are no files selected for viewing
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
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
134 changes: 134 additions & 0 deletions
134
hazelcast/src/main/java/com/hazelcast/internal/partition/MigrationEventImpl.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,134 @@ | ||
/* | ||
* Copyright (c) 2008-2019, 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.internal.partition; | ||
|
||
import com.hazelcast.cluster.Member; | ||
import com.hazelcast.internal.partition.impl.PartitionDataSerializerHook; | ||
import com.hazelcast.nio.ObjectDataInput; | ||
import com.hazelcast.nio.ObjectDataOutput; | ||
import com.hazelcast.nio.serialization.IdentifiedDataSerializable; | ||
import com.hazelcast.partition.MigrationEvent; | ||
import com.hazelcast.partition.MigrationListener; | ||
import com.hazelcast.partition.MigrationProgress; | ||
import com.hazelcast.partition.Partition; | ||
import com.hazelcast.partition.PartitionService; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* An event fired when a partition migration starts, completes or fails. | ||
* | ||
* @see Partition | ||
* @see PartitionService | ||
* @see MigrationListener | ||
*/ | ||
public class MigrationEventImpl implements MigrationEvent, IdentifiedDataSerializable { | ||
|
||
private MigrationProgress progress; | ||
private int partitionId; | ||
private int replicaIndex; | ||
private Member source; | ||
private Member destination; | ||
private boolean success; | ||
private long elapsedTime; | ||
|
||
public MigrationEventImpl() { | ||
} | ||
|
||
public MigrationEventImpl(MigrationProgress progress, int partitionId, int replicaIndex, Member source, Member destination, | ||
boolean success, long elapsedTime) { | ||
this.progress = progress; | ||
this.partitionId = partitionId; | ||
this.replicaIndex = replicaIndex; | ||
this.source = source; | ||
this.destination = destination; | ||
this.success = success; | ||
this.elapsedTime = elapsedTime; | ||
} | ||
|
||
@Override | ||
public int getPartitionId() { | ||
return partitionId; | ||
} | ||
|
||
@Override | ||
public int getReplicaIndex() { | ||
return replicaIndex; | ||
} | ||
|
||
@Override | ||
public Member getSource() { | ||
return source; | ||
} | ||
|
||
@Override | ||
public Member getDestination() { | ||
return destination; | ||
} | ||
|
||
@Override | ||
public MigrationProgress getMigrationProgress() { | ||
return progress; | ||
} | ||
|
||
@Override | ||
public boolean isSuccess() { | ||
return success; | ||
} | ||
|
||
@Override | ||
public long getElapsedTime() { | ||
return elapsedTime; | ||
} | ||
|
||
public void writeData(ObjectDataOutput out) throws IOException { | ||
out.writeObject(progress); | ||
out.writeInt(partitionId); | ||
out.writeInt(replicaIndex); | ||
out.writeObject(source); | ||
out.writeObject(destination); | ||
out.writeBoolean(success); | ||
out.writeLong(elapsedTime); | ||
} | ||
|
||
public void readData(ObjectDataInput in) throws IOException { | ||
progress = in.readObject(); | ||
partitionId = in.readInt(); | ||
replicaIndex = in.readInt(); | ||
source = in.readObject(); | ||
destination = in.readObject(); | ||
success = in.readBoolean(); | ||
elapsedTime = in.readLong(); | ||
} | ||
|
||
@Override | ||
public int getFactoryId() { | ||
return PartitionDataSerializerHook.F_ID; | ||
} | ||
|
||
@Override | ||
public int getClassId() { | ||
return PartitionDataSerializerHook.MIGRATION_EVENT; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MigrationEventImpl{" + "progress=" + progress + ", partitionId=" + partitionId + ", replicaIndex=" + replicaIndex | ||
+ ", source=" + source + ", destination=" + destination + ", success=" + success + ", elapsedTime=" + elapsedTime | ||
+ "ms}"; | ||
} | ||
} |
Oops, something went wrong.