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

Feature/sentinel pigeon adapter #781

Merged
merged 20 commits into from
Jun 11, 2019

Conversation

wchswchs
Copy link
Contributor

@wchswchs wchswchs commented May 21, 2019

Describe what this PR does / why we need it

This PR provides RPC framework Pigeon adapter for Sentinel.

Does this pull request fix one issue?

Features #780

Describe how you did it

Add default fallback and provider & invoker interceptor

Describe how to verify it

Run sentinel-demo-pigeon

Special notes for reviews

@CLAassistant
Copy link

CLAassistant commented May 21, 2019

CLA assistant check
All committers have signed the CLA.

@codecov-io
Copy link

codecov-io commented May 21, 2019

Codecov Report

Merging #781 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #781      +/-   ##
============================================
+ Coverage     41.72%   41.73%   +0.01%     
  Complexity     1377     1377              
============================================
  Files           304      304              
  Lines          8764     8764              
  Branches       1182     1182              
============================================
+ Hits           3657     3658       +1     
  Misses         4660     4660              
+ Partials        447      446       -1
Impacted Files Coverage Δ Complexity Δ
...ava/com/alibaba/csp/sentinel/node/ClusterNode.java 100% <0%> (+4.76%) 8% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 281d342...67bdf22. Read the comment docs.

@jasonjoo2010 jasonjoo2010 force-pushed the feature/sentinel-pigeon-adapter branch from 7fe6827 to 834caec Compare May 21, 2019 13:09
@jasonjoo2010 jasonjoo2010 force-pushed the feature/sentinel-pigeon-adapter branch from 834caec to b838dde Compare May 21, 2019 13:16
wchswchs added 2 commits May 21, 2019 22:18
add pigeon adapter
@wchswchs wchswchs force-pushed the feature/sentinel-pigeon-adapter branch from b838dde to 1b34855 Compare May 21, 2019 14:22
@sczyh30 sczyh30 added area/integrations Issues or PRs related to integrations with open-source components to-review To review labels May 21, 2019
Copy link
Collaborator

@jasonjoo2010 jasonjoo2010 left a comment

Choose a reason for hiding this comment

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

Using only english and describing clearly in commits' history maybe better.

Copy link
Collaborator

@jasonjoo2010 jasonjoo2010 left a comment

Choose a reason for hiding this comment

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

And maybe we should add tests to save the poor coverage. Please reference to sentinel-dubbo-adapter


<properties>
<java.source.version>1.8</java.source.version>
<java.target.version>1.8</java.target.version>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why set the target to java8? Is there a library requiring this?

Target version is set to 1.7 in parent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added test & remove jdk version 1.8 properties

@wchswchs
Copy link
Contributor Author

Using only english and describing clearly in commits' history maybe better.

ok,next commit begin to use en.

}

@Override
public void afterThrowing(InvokerContext invokerContext, Throwable throwable) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not familiar with Pigeon, but I guess the afterThrowing will be triggered when exceptions are thrown. We need to trace the exception here using Tracer.traceEntry(ex, entry). And if the postInvoke is not invoked later, we need to exit the entry here.

Copy link
Contributor Author

@wchswchs wchswchs May 24, 2019

Choose a reason for hiding this comment

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

I reviewed pigeon code, you are right, afterThrowing will be invoded when method invoked throwing exceptions, so trace the exception needed to be placed into afterThrowing. And postInvoke will be invoked after method invoked, so exit entry needed to be placed into postInvoke. I will resolve these problem at once.


@Override
public void preInvoke(InvokerContext invokerContext) {
Entry methodEntry = null;
Copy link
Member

@sczyh30 sczyh30 May 23, 2019

Choose a reason for hiding this comment

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

In my understanding, the response time should be calculated between preInvoke and postInvoke hook, so here if we exit the entry in preInvoke, the RT will be wrong. The context, as well as the invocation chain, would also not be kept. You'll need to call entry.exit() in postInvoke hook. You may need to carry the Entry via InvokerContext.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed these 2 problems.


@Override
public void postInvoke(InvokerContext invokerContext) {
Entry methodEntry = ContextUtil.getContext().getCurEntry();
Copy link
Member

Choose a reason for hiding this comment

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

Can we guarantee the preInvoke and postInvoke of one invocation are invoked in the same thread? If they were called in different threads, the context would be wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can carry the Entry in InvokerContext?

Copy link
Contributor Author

@wchswchs wchswchs May 27, 2019

Choose a reason for hiding this comment

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

I'm sure preInvoke and postInvoke of one invocation are invoked in the same thread, because of the attribute of InvokeContext in Pigeon must be Serializable, but Entry is not Serializable now and I think Entry don't need to Serializable, so i use ContextUtil to get current Entry.

<artifactId>sentinel-demo-pigeon</artifactId>

<repositories>
<repository>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's not necessary to add the snapshot repository here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed snapshot.

Copy link
Member

Choose a reason for hiding this comment

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

Why is github-dianping-maven-repo is needed here? I've tried the URL and it's 400 bad request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because pigeon dependency can be fetched only from github-dianping-maven-repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is github-dianping-maven-repo is needed here? I've tried the URL and it's 400 bad request.

You can compiled the root of sentinel, it's successful.

<!-- Dependency for facebook -->
<dependency>
<groupId>com.facebook.swift</groupId>
<artifactId>swift-annotations</artifactId>
Copy link
Member

@sczyh30 sczyh30 May 31, 2019

Choose a reason for hiding this comment

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

Do the dependencies about com.facebook.swift make sense?

Copy link
Contributor Author

@wchswchs wchswchs Jun 1, 2019

Choose a reason for hiding this comment

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

Pigeon provider initialization need to swift dependency, so I add facebook dependencies related to pom.

@sczyh30
Copy link
Member

sczyh30 commented Jun 4, 2019

I've noticed that the com.dianping:pigeon module is absent in Maven Central and can only be retrieved from a GitHub repo, which is not a standard case. Maybe it's more appropriate to be in an individual repo (e.g. create a new sentinel-pigeon-adapter repo under sentinel-group). You can submit a PR to add the repo link in awesone-sentinel.md.

@wchswchs wchswchs closed this Jun 5, 2019
@wchswchs wchswchs reopened this Jun 5, 2019
@wchswchs
Copy link
Contributor Author

wchswchs commented Jun 5, 2019

I've noticed that the com.dianping:pigeon module is absent in Maven Central and can only be retrieved from a GitHub repo, which is not a standard case. Maybe it's more appropriate to be in an individual repo (e.g. create a new sentinel-pigeon-adapter repo under sentinel-group). You can submit a PR to add the repo link in awesone-sentinel.md.

ok, I have added sentinel-pigeon-adapter into awesome.

@sczyh30
Copy link
Member

sczyh30 commented Jun 5, 2019

It might be better if you could create a new repo sentinel-pigeon-adapter and put your module into it (without other parts of Sentinel), then link in awesone-sentinel.md, which can be more clear :)

@wchswchs
Copy link
Contributor Author

wchswchs commented Jun 7, 2019

I have removed sentinel-pigeon-adapter from sentinel-adapter and linked sentinel-pigeon-adapter to my repo.

@wchswchs wchswchs closed this Jun 7, 2019
@wchswchs wchswchs reopened this Jun 7, 2019
@sczyh30
Copy link
Member

sczyh30 commented Jun 10, 2019

But I think pigeon integration is equally important to dubbo, why couldn't be placed into sentinel-adapter?

Yes it's indeed equally important to Dubbo, but it's not deployed to Maven Central and its way to manage libs is confusing (and not standard). We might only accept the libraries that has been deployed to Maven Central or else valid Maven repositories (e.g. Spring repo).

@sczyh30
Copy link
Member

sczyh30 commented Jun 11, 2019

Now that the adapter code has been migrated to sentinel-pigeon-adapter repo, please also remove the relevant code in this PR and only keep the change for awesome-sentinel.md.

@sczyh30
Copy link
Member

sczyh30 commented Jun 11, 2019

By the way, would you like to donate sentinel-pigeon-adapter to sentinel-group org? You could join the org and manage your repo here.

@wchswchs
Copy link
Contributor Author

Now that the adapter code has been migrated to sentinel-pigeon-adapter repo, please also remove the relevant code in this PR and only keep the change for awesome-sentinel.md.

I have removed the relevant code with pigeon adapter.

@wchswchs
Copy link
Contributor Author

By the way, would you like to donate sentinel-pigeon-adapter to sentinel-group org? You could join the org and manage your repo here.

How should I do?

@sczyh30
Copy link
Member

sczyh30 commented Jun 11, 2019

By the way, would you like to donate sentinel-pigeon-adapter to sentinel-group org? You could join the org and manage your repo here.

How should I do?

You could refer to https://help.github.com/en/articles/transferring-a-repository. The target org is sentinel-group.

@wchswchs
Copy link
Contributor Author

wchswchs commented Jun 11, 2019

By the way, would you like to donate sentinel-pigeon-adapter to sentinel-group org? You could join the org and manage your repo here.

How should I do?

You could refer to https://help.github.com/en/articles/transferring-a-repository. The target org is sentinel-group.

ok

Copy link
Member

@sczyh30 sczyh30 left a comment

Choose a reason for hiding this comment

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

LGTM

@sczyh30 sczyh30 merged commit e3b9f99 into alibaba:master Jun 11, 2019
@sczyh30
Copy link
Member

sczyh30 commented Jun 11, 2019

Thanks for contributing. Once the transfer is finished, I'll update the awesome-sentinel.md :)

@wchswchs
Copy link
Contributor Author

Thanks for contributing. Once the transfer is finished, I'll update the awesome-sentinel.md :)

When I transfer the repo to sentinel-group, it tells me you don’t have the permission to create repositories on sentinel-group.

@sczyh30
Copy link
Member

sczyh30 commented Jun 11, 2019

Thanks for contributing. Once the transfer is finished, I'll update the awesome-sentinel.md :)

When I transfer the repo to sentinel-group, it tells me you don’t have the permission to create repositories on sentinel-group.

I've invited you to join https://github.com/sentinel-group. Once you've joined you could transfer the repo.

@wchswchs
Copy link
Contributor Author

Thanks for contributing. Once the transfer is finished, I'll update the awesome-sentinel.md :)

When I transfer the repo to sentinel-group, it tells me you don’t have the permission to create repositories on sentinel-group.

I've invited you to join https://github.com/sentinel-group. Once you've joined you could transfer the repo.

I have transfered sentinel-pigeon to sentinel-group. :)

@sczyh30
Copy link
Member

sczyh30 commented Jun 11, 2019

Nice, great work! 👍

@sczyh30 sczyh30 removed the to-review To review label Jun 11, 2019
@sczyh30 sczyh30 mentioned this pull request Jun 11, 2019
CST11021 pushed a commit to CST11021/Sentinel that referenced this pull request Nov 3, 2021
[RIP-9] Added sample English documents of English transaction messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/integrations Issues or PRs related to integrations with open-source components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants