-
Notifications
You must be signed in to change notification settings - Fork 31
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
Configuration backup/restore in online mode #145
Configuration backup/restore in online mode #145
Conversation
* destroy command does nothing. | ||
* </p> | ||
*/ | ||
|
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.
Empty line.
public void apply(OnlineCommandContext occ) throws CommandFailedException, IOException, CliException { | ||
if (SnapshotBackup.this.snapshotName != null) { | ||
throw new CommandFailedException("Snapshot was already backed up as " | ||
+ SnapshotBackup.this.snapshotName); |
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.
"Snapshot was already taken: " + SnapshotBackup.this.snapshotName
snapshot = modelNodeResult.stringValue(); | ||
} | ||
// returns absolute path, but we need just the name of snapshot | ||
snapshot = snapshot.substring(snapshot.lastIndexOf(File.separator) + 1); |
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.
Is using File.separator
here accurate? What happens if I'm running on Linux and the server is on Windows?
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.
Any idea how to handle this properly? Thing is snapshotName as value of --server-config
parameter for reload
could not be absolute path.
Note, File.separator
is already used in AddModule.
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.
Well file names on Windows can contain neither /
nor \
. So if the string contains /
, it obviously isn't Windows and you can split on /
, otherwise you split on \
.
Re AddModule
: this command only makes sense when running on the same system as the server. That doesn't apply in this situation.
@@ -0,0 +1,5 @@ | |||
package org.wildfly.extras.creaper.test; | |||
|
|||
/** Category marker for tests that require WildFly and can't run with AS7. */ |
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.
The comment is clearly copy & paste from WildFlyTests
. Please update.
@@ -28,12 +28,16 @@ | |||
<version.wildfly10>10.0.0.Final</version.wildfly10> | |||
<version.wildfly10.core>2.0.10.Final</version.wildfly10.core> | |||
<version.wildfly10.arquillian>1.1.0.Alpha1</version.wildfly10.arquillian> | |||
<version.wildfly11>11.0.0.Alpha1-SNAPSHOT</version.wildfly11> |
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.
Snapshot dependencies are bad. No idea how to fix this...
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.
It can be replaced with <version.wildfly11>11.0.0.Alpha1</version.wildfly11>
.
It will be first valid public value. It can lead user to realize what is going on here. Better than SNAPSHOT, which looks like a bug.
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.
Hmm, OK, but at least add a comment. Something like:
<!-- doesn't exist yet; update when there's a public release of WildFly 11 -->
<version.wildfly11>11.0.0.Alpha1</version.wildfly11>
And a similar comment to the wildfly11
profile.
|
||
@Before | ||
public void connect() throws IOException { | ||
client = getManagementClient(); |
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.
Is the getManagementClient
method used elsewhere? I can only see that it's used here, in which case please inline it.
} | ||
|
||
@Test | ||
public void correctUsage() throws CommandFailedException, IOException, OperationException, InterruptedException { |
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.
restoreTwice
is apparently also correct usage, so we'll need to update the names.
import com.google.common.base.Strings; | ||
|
||
/** | ||
* Provides a pair of online commands to backup and then restore the snapshot. |
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.
This needs to be reworded. We're not backing up and then restoring the snapshot. We're backing up and then restoring application server configuration, and we're using the snapshot features to do so. I'd suggest:
Provides a pair of online commands to backup and then restore application server configuration while the server is running. Backup consists of taking a snapshot, restore then means reloading the server from the snapshot.
* Provides a pair of online commands to backup and then restore the snapshot. | ||
* <p> | ||
* The {@code backup} command must be applied before {@code restore}, and | ||
* {@code backup} can be applied once. If any one of these rules is violated, an |
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.
This reads weird. I'd suggest: The {@code backup} command must be applied before {@code restore}, {@code backup} can be applied once, and then {@code restore} can be applied many times.
* @param snapshotAbsolutePath Absolute path to snapshot | ||
* @return name of snapshot | ||
*/ | ||
private String getSnapshotName(String snapshotAbsolutePath) { |
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.
As the first line of the method body, I'd expect a comment along the lines of Windows file names can't contain /, so if there's a / in the full path, it's not Windows
.
OK, looks mostly good. When you fix the one last thing, please also squash. |
1c3a8af
to
af7d435
Compare
PR now contains just squashed commit. |
public void apply(OnlineCommandContext occ) throws CommandFailedException, IOException, InterruptedException, | ||
TimeoutException { | ||
if (SnapshotBackup.this.snapshotName == null) { | ||
throw new CommandFailedException("There's no snapshot backup to restore"); |
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.
Ah, one more! :-) There's no snapshot to restore
<!-- doesn't exist yet; update when there's a public release of WildFly 11 --> | ||
<version.wildfly11>11.0.0.Alpha1</version.wildfly11> | ||
<version.wildfly11.core>3.0.0.Alpha10</version.wildfly11.core> | ||
<version.wildfly11.arquillian>2.0.0.Final</version.wildfly11.arquillian> | ||
|
||
<managementPort.as7>9999</managementPort.as7> | ||
<managementPort.wildfly>9990</managementPort.wildfly> | ||
|
||
<ignoredCategory.as7>org.wildfly.extras.creaper.test.WildFlyTests</ignoredCategory.as7> |
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.
Now I'm thinking... should this line also contain WildFly11Tests
?
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.
I think no, because SnapshotBackupTest is declared as Category {WildFlyTests, WildFly11Tests}
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.
So the WildFly11Tests
category is meant as a "subset" of WildFlyTests
? And everytime a test is in category WildFly11Tests
, it also has to be in category WildFlyTests
? That kinda sorta makes sense, but should be at least documented.
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.
I have added comment to WildFly11Tests.
621e113
to
aa5f06b
Compare
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.
OK, this is the last thing :-)
// returns absolute path, but we need just the name of snapshot | ||
String snapshotName = getSnapshotName(snapshotAbsolutePath); | ||
if (Strings.isNullOrEmpty(snapshotAbsolutePath)) { | ||
throw new CommandFailedException("Unable to take snapshot"); |
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.
Ah, here's an idea: if the :take-snapshot
operation fails, we're silently dropping the error message. That's bad. If there's one, it should be added to this exception.
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.
Looking into the code, I believe execute() should take care of that - if result is failed throws exception. Now it seems to me this check is unnecessary. Also unnecessary is if (modelNodeResult.isSuccess()
WDYT?
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.
OnlineManagementClient.execute
won't throw in case of an error. However, you can do ModelNodeResult.assertSuccess()
, which would be enough in this case IMHO.
aa5f06b
to
aa7663a
Compare
Could you please remove the |
Done |
Not really, you only renamed the PR :-) |
aa7663a
to
d5a591f
Compare
Done |
I can't believe that :O |
I'd like to point out that there were PRs that took more than a month to merge. Compared to that, this one was pretty fast ;-) |
The ConfigurationFileBackup set of offline commands facilitate taking a backup of the server configuration and later restoring it. It would be very useful to have the same possibility in the online mode, e.g. using the existing snapshot function.