-
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
commands for resource adapter manipulation #146
Conversation
ops.add(address, Values.of("class-name", className) | ||
.and("jndi-name", localJndiName).and("use-java-context", useJavaContext)); | ||
if (properties.size() > 0) { | ||
|
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.
Why the empty line? :-)
if (properties.size() > 0) { | ||
|
||
Iterator it = properties.entrySet().iterator(); | ||
while (it.hasNext()) { |
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.
Why not for (Map.Entry<String, String> entry : properties.entrySet()) { ... }
?
} | ||
} | ||
|
||
|
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 lines...
/** | ||
* Adds admin object to existing resource adapter | ||
*/ | ||
public class AddAdminObjectToRA implements OnlineCommand { |
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.
Should probably be final
.
private Map<String, String> properties = new HashMap<String, String>(); | ||
|
||
public Builder(String poolName, String localJndiName, String className, boolean useJavaContext, | ||
String resourceAdapterId) { |
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.
Looks like a lot of parameters. What about using builder methods for them, or most of them? Presence/absence of mandatory values can be validates in the build
method.
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 it necessary? I'd like to keep some consistency in relation to the other RA commands.
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.
Consistency is good, but sanity is better. You have 5 parameters, 4 of them are strings. Invocation of such a constructor is basically unreadable. If you feel strongly about consistency with other RA commands, feel free to use parameter-less constructors for all their builders :-)
private OnlineManagementClient client; | ||
private Operations ops; | ||
private Administration admin; | ||
private static final String RA_ID = "genericjmsRA"; |
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.
Order of fields.
ModelNodeResult res = ops.readResource(Address.subsystem("resource-adapters").and("resource-adapter", RA_ID)); | ||
res.assertSuccess(); | ||
} | ||
} |
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.
Negative test case?
private OnlineManagementClient client; | ||
private Operations ops; | ||
private Administration admin; | ||
private static final String RA_ID = "genericjmsRA"; |
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.
Order of fields.
private OnlineManagementClient client; | ||
private Operations ops; | ||
private Administration admin; | ||
private static final String RA_ID = "genericjmsRA"; |
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.
Order of fields.
private OnlineManagementClient client; | ||
private Operations ops; | ||
private Administration admin; | ||
private static final String RA_ID = "genericjmsRA"; |
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.
Order of fields.
I will review more tomorrow, but I'd like to point out that while I want command classes as much immutable as possible, builders don't have to be. That's one of the big points of using them -- mutate as you wish while you're building the command, but once you build it, there's no going back. |
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, I think this is almost done :-)
.and("resource-adapter", resourceAdapterId) | ||
.and("connection-definitions", poolName).and("config-properties", pair.getKey()); | ||
ops.add(configPropsAddress, Values.of("value", pair.getValue())); | ||
} |
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.
Did you consider creating a Batch
and then performing all ops in a single "transaction"? It's not strictly required, but very nice to have :-)
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.
Tbh I didn't.
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 won't force you to do it, but it would be nice :-)
* Adds new resource adapter | ||
*/ | ||
public final class AddResourceAdapter implements OnlineCommand { | ||
private final String id; |
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.
Two spaces between final
and String
.
|
||
public AddResourceAdapter build() { | ||
|
||
|
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 lines.
|
||
/** | ||
* @param resourceAdapterId name of resource adapter | ||
*/ |
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.
Most methods in this PR don't have a Javadoc. I don't think this one needs to have it, especially if it really doesn't say anything.
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 usually have some javadoc on builder, so I used the same hare...
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's not a problem, feel free to keep it. But frankly, this kind of javadoc helps noone -- it merely restates what is obvious from the code.
res.assertSuccess(); | ||
} | ||
|
||
@Test(expected = org.wildfly.extras.creaper.core.CommandFailedException.class) |
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.
Import that class?
res.assertSuccess(); | ||
} | ||
|
||
@Test(expected = org.wildfly.extras.creaper.core.CommandFailedException.class) |
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.
Import that class?
res.assertSuccess(); | ||
} | ||
|
||
@Test(expected = org.wildfly.extras.creaper.core.CommandFailedException.class) |
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.
Import that class?
@Test(expected = org.wildfly.extras.creaper.core.CommandFailedException.class) | ||
public void addNewRaNegativeTestCase() throws Exception { | ||
client.apply(new AddResourceAdapter.Builder(RA_ID, "org.jboss.nonexsitingmodule", TransactionType.XA).build()); | ||
admin.reloadIfRequired(); |
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 this needed? The exception will be thrown on the first line, no?
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, I've looked at how you're using builders and I think maybe we should move that one constructor back to a trivial builder. There's too many builders that only have constructor and no additional method, and consistency would be good here.
Other than that, one single move to Batch
and it's done :-)
Address configPropsAddress = Address.subsystem("resource-adapters") | ||
.and("resource-adapter", resourceAdapterId) | ||
.and("admin-objects", poolName).and("config-properties", pair.getKey()); | ||
ops.add(configPropsAddress, Values.of("value", pair.getValue())); |
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 could also use Batch
.
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.
Please squash and I'll merge.
@okalmanRH, don't believe him, I heard that 2 days ago :P |
@mchoma is right, you shouldn't believe me. I won't merge yet, because your tests are failing on EAP 6 :-) |
Is there any action needed from me because of it? |
Yes? :-) |
OK, I'll try to be more specific: are the commands supposed to work with EAP 6? (I don't see why not.) If yes, the tests should pass. If not, it should be documented, the commands should fail early (using something like |
maybe dumb question, but how do I run the testsuite against EAP6 or its WildFly equivalent? |
NP, it's a good question. See https://github.com/wildfly-extras/creaper/blob/master/CONTRIBUTING.md |
So the issue comes from org.jboss.genericjms module in EAP6. Because it requires another module with jms jars which needs to be present. In EAP7 this module is marked in module.xml as optional so everything works fine. |
What would that mean for end users trying to use these commands? |
It depends on use case. |
OK, so is there a simple way to adjust the tests for EAP 6 so that they pass? Or would that mean that the test would have to download a JAR and whatnot, in which case I'd prefer to just skip them on EAP 6? |
We can try to modify module.xml and add optional="true", but I don't know whether it's suitable solution for you. |
I'm not a fan. I'd rather skip the test, with a comment. Something like // doesn't work on AS7/EAP6 because ...
assumeThat(client.version().greaterThanOrEqualTo(...)); |
@@ -26,6 +29,7 @@ | |||
@Before | |||
public void connect() throws IOException { | |||
client = ManagementClient.online(OnlineOptions.standalone().localDefault().build()); | |||
Assume.assumeTrue(client.version().greaterThanOrEqualTo(ServerVersion.VERSION_2_1_0)); |
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.
Did the change really happen in WildFly 8.1.0?
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, that first builds of EAP7 were based on WF8, or not?
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.
Hm.... It seems that WF8.1 doesn't contain the fix... I'll investigate this further
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.
No, they were not :-) EAP 7.0 (loosely) corresponds to WildFly 10.
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.
WF9 contains the fix, so I've set version to 3.0.0
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.
Agreed, the tests pass in the wildfly9
profile.
OK, could you please squash? |
No description provided.