-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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,320 additions
and
643 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
112 changes: 112 additions & 0 deletions
112
hazelcast/src/main/java/com/hazelcast/internal/partition/MigrationStateImpl.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,112 @@ | ||
/* | ||
* 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.internal.partition.impl.PartitionDataSerializerHook; | ||
import com.hazelcast.nio.ObjectDataInput; | ||
import com.hazelcast.nio.ObjectDataOutput; | ||
import com.hazelcast.nio.serialization.IdentifiedDataSerializable; | ||
import com.hazelcast.partition.MigrationState; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Summary of the migration state. | ||
* Main implementation of {@link MigrationState}. | ||
*/ | ||
public class MigrationStateImpl implements MigrationState, IdentifiedDataSerializable { | ||
|
||
private long startTime; | ||
private int plannedMigrations; | ||
private int completedMigrations; | ||
private long totalElapsedTime; | ||
|
||
public MigrationStateImpl() { | ||
} | ||
|
||
public MigrationStateImpl(long startTime, int plannedMigrations, int completedMigrations, long totalElapsedTime) { | ||
this.startTime = startTime; | ||
this.plannedMigrations = plannedMigrations; | ||
this.completedMigrations = completedMigrations; | ||
this.totalElapsedTime = totalElapsedTime; | ||
} | ||
|
||
@Override | ||
public long getStartTime() { | ||
return startTime; | ||
} | ||
|
||
@Override | ||
public int getPlannedMigrations() { | ||
return plannedMigrations; | ||
} | ||
|
||
@Override | ||
public int getCompletedMigrations() { | ||
return completedMigrations; | ||
} | ||
|
||
@Override | ||
public int getRemainingMigrations() { | ||
return plannedMigrations - completedMigrations; | ||
} | ||
|
||
@Override | ||
public long getTotalElapsedTime() { | ||
return totalElapsedTime; | ||
} | ||
|
||
public MigrationStateImpl onComplete(long elapsed) { | ||
return onComplete(1, elapsed); | ||
} | ||
|
||
public MigrationStateImpl onComplete(int migrations, long elapsed) { | ||
return new MigrationStateImpl(startTime, plannedMigrations, completedMigrations + migrations, totalElapsedTime + elapsed); | ||
} | ||
|
||
@Override | ||
public void writeData(ObjectDataOutput out) throws IOException { | ||
out.writeLong(startTime); | ||
out.writeLong(totalElapsedTime); | ||
out.writeInt(plannedMigrations); | ||
out.writeInt(completedMigrations); | ||
} | ||
|
||
@Override | ||
public void readData(ObjectDataInput in) throws IOException { | ||
startTime = in.readLong(); | ||
totalElapsedTime = in.readLong(); | ||
plannedMigrations = in.readInt(); | ||
completedMigrations = in.readInt(); | ||
} | ||
|
||
@Override | ||
public int getFactoryId() { | ||
return PartitionDataSerializerHook.F_ID; | ||
} | ||
|
||
@Override | ||
public int getClassId() { | ||
return PartitionDataSerializerHook.MIGRATION_EVENT; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MigrationState{startTime=" + startTime + ", plannedMigrations=" + plannedMigrations | ||
+ ", completedMigrations=" + completedMigrations + ", totalElapsedTime=" + totalElapsedTime + "ms}"; | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
hazelcast/src/main/java/com/hazelcast/internal/partition/PartitionLostEventImpl.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,119 @@ | ||
/* | ||
* 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.internal.partition.impl.PartitionDataSerializerHook; | ||
import com.hazelcast.nio.Address; | ||
import com.hazelcast.nio.ObjectDataInput; | ||
import com.hazelcast.nio.ObjectDataOutput; | ||
import com.hazelcast.nio.serialization.IdentifiedDataSerializable; | ||
import com.hazelcast.partition.Partition; | ||
import com.hazelcast.partition.PartitionLostEvent; | ||
import com.hazelcast.partition.PartitionLostListener; | ||
import com.hazelcast.partition.PartitionService; | ||
import com.hazelcast.spi.partition.IPartitionLostEvent; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* The event that is fired when a partition lost its owner and all backups. | ||
* | ||
* @see Partition | ||
* @see PartitionService | ||
* @see PartitionLostListener | ||
*/ | ||
public class PartitionLostEventImpl implements PartitionLostEvent, IPartitionLostEvent, IdentifiedDataSerializable { | ||
|
||
private int partitionId; | ||
|
||
private int lostBackupCount; | ||
|
||
private Address eventSource; | ||
|
||
public PartitionLostEventImpl() { | ||
} | ||
|
||
public PartitionLostEventImpl(int partitionId, int lostBackupCount, Address eventSource) { | ||
this.partitionId = partitionId; | ||
this.lostBackupCount = lostBackupCount; | ||
this.eventSource = eventSource; | ||
} | ||
|
||
/** | ||
* Returns the lost partition ID. | ||
* | ||
* @return the lost partition ID. | ||
*/ | ||
@Override | ||
public int getPartitionId() { | ||
return partitionId; | ||
} | ||
|
||
/** | ||
* Returns the number of lost backups for the partition. 0: the owner, 1: first backup, 2: second backup... | ||
* If all replicas of a partition are lost, {@link InternalPartition#MAX_BACKUP_COUNT} is returned. | ||
*/ | ||
@Override | ||
public int getLostBackupCount() { | ||
return lostBackupCount; | ||
} | ||
|
||
@Override | ||
public int getLostReplicaIndex() { | ||
return lostBackupCount; | ||
} | ||
|
||
/** | ||
* Returns the address of the node that dispatches the event | ||
* | ||
* @return the address of the node that dispatches the event | ||
*/ | ||
@Override | ||
public Address getEventSource() { | ||
return eventSource; | ||
} | ||
|
||
@Override | ||
public void writeData(ObjectDataOutput out) throws IOException { | ||
out.writeInt(partitionId); | ||
out.writeInt(lostBackupCount); | ||
out.writeObject(eventSource); | ||
} | ||
|
||
@Override | ||
public void readData(ObjectDataInput in) throws IOException { | ||
partitionId = in.readInt(); | ||
lostBackupCount = in.readInt(); | ||
eventSource = in.readObject(); | ||
} | ||
|
||
@Override | ||
public int getFactoryId() { | ||
return PartitionDataSerializerHook.F_ID; | ||
} | ||
|
||
@Override | ||
public int getClassId() { | ||
return PartitionDataSerializerHook.PARTITION_LOST_EVENT; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getName() + "{partitionId=" + partitionId + ", lostBackupCount=" + lostBackupCount + ", eventSource=" | ||
+ eventSource + '}'; | ||
} | ||
} |
Oops, something went wrong.