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

Add new turtle test node based directly on NodeBase #353

Open
wants to merge 6 commits into
base: v6.x.x
Choose a base branch
from

Conversation

gavin-norman-sociomantic

(Currently based on #350. Only the last commit is relevant.)

@gavin-norman-sociomantic
Copy link
Author

gavin-norman-sociomantic commented Aug 2, 2018

I believe the separation of turtle node from the actual node implementation is a historical artefact from the days when the fake nodes lived partially in turtle. It seems to be unnecessary now.

@gavin-norman-sociomantic
Copy link
Author

sociomantic-tsunami/dlsproto#101 gives a rough example of how this change simplifies the code for a fake node.

@mihails-strasuns
Copy link

Hm, this doesn't look like any code I have written and turtle definitely doesn't care so I'd say "whatever fits you best" :)

@gavin-norman-sociomantic
Copy link
Author

It was derived from code in turtle that you wrote originally.

@mihails-strasuns
Copy link

I pretty sure that it was you who wrote that code in turtle originally :) I copied it to swarm with almost no changes when splitting things.

Notes:
1. Restarting the node *does not* clear any data in its storage
engine. To do that, call clear().
2. You must call stop() first, before calling restart().

Choose a reason for hiding this comment

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

This is extremely weird tbh. If you need to call stop first, it is just start, not restart.

Choose a reason for hiding this comment

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

Agreed. I have no memory of why we did it like this.

@gavin-norman-sociomantic
Copy link
Author

I pretty sure that it was you who wrote that code in turtle originally :) I copied it to swarm with almost no changes when splitting things.

Could be :) Mainly I'm interested in your opinion on the concept, and whether I'm missing some subtlety of turtle.

@mihails-strasuns
Copy link

AFAIR turtle only cares that nodes stop printing messages once unregister is called and everything else is completely up to you.

@gavin-norman-sociomantic
Copy link
Author

Adapted with working restart. (Still super rough.)

@gavin-norman-sociomantic
Copy link
Author

Tidied up.

@gavin-norman-sociomantic
Copy link
Author

D2 fixes.

@gavin-norman-sociomantic
Copy link
Author

Still TODO:

  • Release notes (new feature / deprecation).
  • Decide whether the changes to NodeBase are breaking, and whether there's a non-breaking way of doing them.

@gavin-norman-sociomantic gavin-norman-sociomantic changed the title [WIP] Add new turtle test node based directly on NodeBase Add new turtle test node based directly on NodeBase Aug 22, 2018
src/swarm/node/model/NeoNode.d Show resolved Hide resolved
src/turtle/env/model/Node.d Show resolved Hide resolved
src/swarm/node/model/NeoNode.d Show resolved Hide resolved

static this ( )
{
log = Log.lookup("testnode");
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm. Is there a way for the fake node implementation to override the testnode log name? It's useful when testing with multiple types of test nodes.

Choose a reason for hiding this comment

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

Yeah, I'll change it to one logger per instance.

ConnectionSetupParams conn_setup_params, Options options, int backlog )
{
verify(!already_created, "Can only have one " ~ idup(this.id) ~
" per turtle test app");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a case for assert?

Choose a reason for hiding this comment

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

Why?


this.register(theScheduler.epoll);
if ( Task.getThis() )
theScheduler.processEvents();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a case where this is not running in task? With the turtle, I don't think so, but I might be mistaken.

Copy link
Contributor

Choose a reason for hiding this comment

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

(note that you require that theScheduler.epoll is something - perhaps that's worth verifying as well?)


***************************************************************************/

abstract public void clear ( );
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, what's the reason for having this abstract method?

Choose a reason for hiding this comment

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

True, it's not required at this level.

( Client.Neo.Get.Notification, Const!(Client.Neo.Get.Args) ) { });
if ( !ok )
return false;

Copy link
Contributor

Choose a reason for hiding this comment

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

if (value[] != "hello") return false;

@nemanja-boric-sociomantic
Copy link
Contributor

Needs rebase now.

@gavin-norman-sociomantic
Copy link
Author

Rebased.

@nemanja-boric-sociomantic
Copy link
Contributor

Hmmmm

./src/swarm/node/model/Node.d(702): Error: class swarm.node.model.Node.TestNode interface function INode.restartListeners isn't implemented
./src/swarm/node/model/Node.d(702): Error: class swarm.node.model.Node.TestNode interface function INode.restartListeners isn't implemented
./src/swarm/node/model/Node.d(702): Error: class swarm.node.model.Node.TestNode interface function INode.restartListeners isn't implemented```

@nemanja-boric-sociomantic
Copy link
Contributor

I also left a review on this PR :-)

@gavin-norman-sociomantic
Copy link
Author

Ohh shit. I changed INodeBase, but only adapted the neo node classes that implement that interface :/

Gavin Norman added 5 commits August 24, 2018 16:34
References to the listeners are required by INodeBase, but these were
previously passed into the ctor from outside, rather than being owned and
controlled by this class. This, combined with the lack of support in ocean
for reopening a shutdown listener, made it impossible to implement a method
to restart the node's listeners.

(The ideal solution, of course, would be to add the missing restart support
to the select listener in ocean, but this will require a major swarm
release.)
(As a counterpart to the existing stopListener.)
There's more than one listener now.
This is intended as a replacement of the existing turtle.env.model.Node.
The reason for the new class is that the turtle/swarm node framework is
currently fairly complicated, with several different classes required to
implement a fake node. The new TestNode derives directly from NodeBase (the
standard base class for swarm nodes), whereas the older Node does not. This
means that to implement a fake node using TestNode, one does not have to
separately write a class deriving from NodeBase.
@gavin-norman-sociomantic
Copy link
Author

Updated.

@mihails-strasuns
Copy link

@gavin-norman-sociomantic was there anything left for this PR from your side? It looks fine to me but there is a plenty of neo stuff I have no idea about :)

@gavin-norman-sociomantic
Copy link
Author

gavin-norman-sociomantic commented Dec 6, 2018

The PR looks sensible to me, in isolation. I think it was waiting on trying to adapt one of the proto fake nodes, to confirm that it works (and is helpful) in practice.

@gavin-norman-sociomantic
Copy link
Author

Ah, this appears to be a test of adapting a *proto to use this: sociomantic-tsunami/dlsproto#101

@gavin-norman-sociomantic gavin-norman-sociomantic modified the milestones: v5.4.0, v5.5.0 Apr 11, 2019
@Geod24 Geod24 changed the base branch from v5.x.x to v6.x.x August 13, 2020 10:24
@Geod24 Geod24 removed this from the v5.5.0 milestone Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants