-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-26748 Add rolling upgrade commands for control.sh #12494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
780bfe8
3431693
9b50aef
6a59cf1
eb71e24
9139c32
7732599
c1b20b1
9d7732e
08e7249
ef3d269
47fd796
f91df3c
010e244
ddf4b39
a8d30a2
dff10f5
9246c33
d17a44e
94a396f
8f9c98a
68c9f01
4afe3ab
9443bc6
db5e9a8
27762a2
40841dd
1ebca3d
1db2c0f
ded0809
d7ce36b
2b488a7
eac64bc
069262e
a5e2562
9c68bc4
c41d4dc
12d78c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * 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.ignite.util; | ||
|
|
||
| import org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeCommand; | ||
| import org.apache.ignite.internal.util.lang.IgnitePair; | ||
| import org.apache.ignite.lang.IgniteProductVersion; | ||
| import org.junit.Test; | ||
|
|
||
| import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_BUILD_VER; | ||
| import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK; | ||
|
|
||
| /** Tests {@link RollingUpgradeCommand} command. */ | ||
| public class RollingUpgradeCommandTest extends GridCommandHandlerClusterByClassAbstractTest { | ||
| /** */ | ||
| public static final String ENABLE = "enable"; | ||
|
|
||
| /** */ | ||
| public static final String DISABLE = "disable"; | ||
|
|
||
| /** */ | ||
| public static final String ROLLING_UPGRADE = "--rolling-upgrade"; | ||
|
|
||
| /** */ | ||
| @Test | ||
| public void testCommands() { | ||
| int res = execute(ROLLING_UPGRADE, DISABLE); | ||
|
|
||
| assertEquals(EXIT_CODE_OK, res); | ||
| assertEquals("Rolling upgrade disabled", lastOperationResult); | ||
|
|
||
| IgniteProductVersion curVer = IgniteProductVersion.fromString(crd.localNode().attribute(ATTR_BUILD_VER)); | ||
|
|
||
| String targetVerStr = curVer.major() + "." + (curVer.minor() + 1) + ".0"; | ||
|
|
||
| res = execute(ROLLING_UPGRADE, ENABLE, targetVerStr); | ||
| assertEquals(EXIT_CODE_OK, res); | ||
|
|
||
| assertTrue(crd.context().rollingUpgrade().enabled()); | ||
|
|
||
| IgniteProductVersion targetVer = IgniteProductVersion.fromString(targetVerStr); | ||
|
|
||
| IgnitePair<IgniteProductVersion> versions = crd.context().rollingUpgrade().versions(); | ||
|
|
||
| assertNotNull(versions); | ||
|
|
||
| assertEquals(curVer, versions.get1()); | ||
| assertEquals(targetVer, versions.get2()); | ||
|
|
||
| assertEquals( | ||
| "Rolling upgrade enabled [currentVersion=" + curVer + ", targetVersion=" + targetVer + ']', | ||
| lastOperationResult | ||
| ); | ||
|
|
||
| res = execute(ROLLING_UPGRADE, DISABLE); | ||
|
|
||
| assertEquals(EXIT_CODE_OK, res); | ||
| assertEquals("Rolling upgrade disabled", lastOperationResult); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /* | ||
| * 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.ignite.internal.management.rollingupgrade; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.ObjectInput; | ||
| import java.io.ObjectOutput; | ||
| import org.apache.ignite.internal.dto.IgniteDataTransferObject; | ||
| import org.apache.ignite.internal.management.api.Argument; | ||
| import org.apache.ignite.internal.management.api.CommandRegistryImpl; | ||
| import org.apache.ignite.internal.management.api.Positional; | ||
| import org.apache.ignite.internal.util.typedef.internal.U; | ||
|
|
||
| /** Rolling upgrade commands. */ | ||
| public class RollingUpgradeCommand extends CommandRegistryImpl { | ||
| /** */ | ||
| public RollingUpgradeCommand() { | ||
| super( | ||
| new RollingUpgradeEnableCommand(), | ||
| new RollingUpgradeDisableCommand() | ||
| ); | ||
| } | ||
|
|
||
| /** Base rolling upgrade command argument. */ | ||
| public static class RollingUpgradeCommandArg extends IgniteDataTransferObject { | ||
|
||
| /** */ | ||
| private static final long serialVersionUID = 0; | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected void writeExternalData(ObjectOutput out) throws IOException { | ||
| // No-op. | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected void readExternalData(ObjectInput in) throws IOException, ClassNotFoundException { | ||
| // No-op. | ||
| } | ||
| } | ||
|
|
||
| /** Rolling upgrade enable command argument. */ | ||
| public static class RollingUpgradeEnableCommandArg extends RollingUpgradeCommandArg { | ||
| /** */ | ||
| private static final long serialVersionUID = 0; | ||
|
|
||
| /** Target version. */ | ||
| @Argument(description = "Target Ignite version", example = "2.18.0") | ||
| @Positional | ||
| private String targetVersion; | ||
|
|
||
| /** */ | ||
| public String targetVersion() { | ||
| return targetVersion; | ||
| } | ||
|
|
||
| /** */ | ||
| public void targetVersion(String targetVersion) { | ||
| this.targetVersion = targetVersion; | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected void writeExternalData(ObjectOutput out) throws IOException { | ||
| U.writeString(out, targetVersion); | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override protected void readExternalData(ObjectInput in) throws IOException, ClassNotFoundException { | ||
| targetVersion = U.readString(in); | ||
| } | ||
| } | ||
|
|
||
| /** Rolling upgrade disable command argument. */ | ||
| public static class RollingUpgradeDisableCommandArg extends RollingUpgradeCommandArg { | ||
| /** */ | ||
| private static final long serialVersionUID = 0; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * 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.ignite.internal.management.rollingupgrade; | ||
|
|
||
| import java.util.Collection; | ||
| import org.apache.ignite.cluster.ClusterNode; | ||
| import org.apache.ignite.internal.management.api.ComputeCommand; | ||
| import org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeCommand.RollingUpgradeDisableCommandArg; | ||
|
|
||
| import static org.apache.ignite.internal.management.api.CommandUtils.coordinatorOrNull; | ||
| import static org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeCommand.RollingUpgradeCommandArg; | ||
|
|
||
| /** Command to disable rolling upgrade mode. */ | ||
| public class RollingUpgradeDisableCommand implements ComputeCommand<RollingUpgradeCommandArg, String> { | ||
| /** {@inheritDoc} */ | ||
| @Override public String description() { | ||
| return "Disable rolling upgrade"; | ||
|
||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override public Class<RollingUpgradeDisableCommandArg> argClass() { | ||
| return RollingUpgradeDisableCommandArg.class; | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override public Class<RollingUpgradeTask> taskClass() { | ||
| return RollingUpgradeTask.class; | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override public Collection<ClusterNode> nodes(Collection<ClusterNode> nodes, RollingUpgradeCommandArg arg) { | ||
| return coordinatorOrNull(nodes); | ||
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * 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.ignite.internal.management.rollingupgrade; | ||
|
|
||
| import java.util.Collection; | ||
| import org.apache.ignite.cluster.ClusterNode; | ||
| import org.apache.ignite.internal.management.api.ComputeCommand; | ||
| import org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeCommand.RollingUpgradeEnableCommandArg; | ||
|
|
||
| import static org.apache.ignite.internal.management.api.CommandUtils.coordinatorOrNull; | ||
| import static org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeCommand.RollingUpgradeCommandArg; | ||
|
|
||
| /** Command to enable rolling upgrade. */ | ||
| public class RollingUpgradeEnableCommand implements ComputeCommand<RollingUpgradeCommandArg, String> { | ||
| /** {@inheritDoc} */ | ||
| @Override public String description() { | ||
| return "Enable rolling upgrade"; | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override public Class<RollingUpgradeEnableCommandArg> argClass() { | ||
| return RollingUpgradeEnableCommandArg.class; | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override public Class<RollingUpgradeTask> taskClass() { | ||
| return RollingUpgradeTask.class; | ||
| } | ||
|
|
||
| /** {@inheritDoc} */ | ||
| @Override public Collection<ClusterNode> nodes(Collection<ClusterNode> nodes, RollingUpgradeCommandArg arg) { | ||
| return coordinatorOrNull(nodes); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move all nested classes to separate files