Skip to content
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

Merged
merged 1 commit into from Nov 22, 2016
Merged

commands for resource adapter manipulation #146

merged 1 commit into from Nov 22, 2016

Conversation

ghost
Copy link

@ghost ghost commented Nov 15, 2016

No description provided.

ops.add(address, Values.of("class-name", className)
.and("jndi-name", localJndiName).and("use-java-context", useJavaContext));
if (properties.size() > 0) {

Copy link
Contributor

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()) {
Copy link
Contributor

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()) { ... }?

}
}


Copy link
Contributor

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 {
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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";
Copy link
Contributor

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();
}
}
Copy link
Contributor

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";
Copy link
Contributor

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";
Copy link
Contributor

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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order of fields.

@Ladicek
Copy link
Contributor

Ladicek commented Nov 15, 2016

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.

Copy link
Contributor

@Ladicek Ladicek left a 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()));
}
Copy link
Contributor

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 :-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I didn't.

Copy link
Contributor

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;
Copy link
Contributor

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() {


Copy link
Contributor

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
*/
Copy link
Contributor

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.

Copy link
Author

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...

Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor

@Ladicek Ladicek left a 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()));
Copy link
Contributor

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.

Copy link
Contributor

@Ladicek Ladicek left a 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.

@mchoma
Copy link
Collaborator

mchoma commented Nov 16, 2016

@okalmanRH, don't believe him, I heard that 2 days ago :P

@Ladicek
Copy link
Contributor

Ladicek commented Nov 16, 2016

@mchoma is right, you shouldn't believe me. I won't merge yet, because your tests are failing on EAP 6 :-)

@Ladicek Ladicek self-assigned this Nov 16, 2016
@Ladicek Ladicek added this to the 1.6.0 milestone Nov 16, 2016
@ghost
Copy link
Author

ghost commented Nov 16, 2016

Is there any action needed from me because of it?

@Ladicek
Copy link
Contributor

Ladicek commented Nov 16, 2016

Yes? :-)

@Ladicek
Copy link
Contributor

Ladicek commented Nov 16, 2016

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 OnlineCommandContext.version.assertAtLeast(ServerVersion.XXX)), and the tests should be in a correct category.

@ghost
Copy link
Author

ghost commented Nov 16, 2016

maybe dumb question, but how do I run the testsuite against EAP6 or its WildFly equivalent?
EDIT: don't bother to answer... it was really dumb question

@Ladicek
Copy link
Contributor

Ladicek commented Nov 16, 2016

@ghost
Copy link
Author

ghost commented Nov 22, 2016

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.

@Ladicek
Copy link
Contributor

Ladicek commented Nov 22, 2016

What would that mean for end users trying to use these commands?

@ghost
Copy link
Author

ghost commented Nov 22, 2016

It depends on use case.
If they want to use generic-ra they have to create new module with jms jars.
If they want to use other ra, like WebSphere, they have to deploy this RA to EAP as deployment.
Our issue is that for test cases I'm using generic RA (as it is probably the only RA which is out of the box available)...

@Ladicek
Copy link
Contributor

Ladicek commented Nov 22, 2016

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?

@ghost
Copy link
Author

ghost commented Nov 22, 2016

We can try to modify module.xml and add optional="true", but I don't know whether it's suitable solution for you.

@Ladicek
Copy link
Contributor

Ladicek commented Nov 22, 2016

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));
Copy link
Contributor

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?

Copy link
Author

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?

Copy link
Author

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

Copy link
Contributor

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.

Copy link
Author

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

Copy link
Contributor

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.

@Ladicek
Copy link
Contributor

Ladicek commented Nov 22, 2016

OK, could you please squash?

@Ladicek Ladicek merged commit eaa92db into wildfly-extras:master Nov 22, 2016
@ghost ghost deleted the ra-config branch November 22, 2016 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants