How to write custom connector for Facebook Presto? - sql

I have setup Presto with mysql connector enabled.
Now I want to write my own connector for a special type of data source.
Custom connector for SQLAlchemy is done. But this time, I am facing dozens of Java classes. What base classes can be used as good starting point? Which interfaces must be implemented? Maybe RawFile connector?
Thank you in advance.

See the developer documentation: https://prestodb.io/docs/current/develop/connectors.html. The example HTTP connector is a good starting point.
You need to implement ConnectorFactory, Connector, ConnectorMetadata,
ConnectorSplitManager, ConnectorHandleResolver, and either ConnectorRecordSetProvider or ConnectorPageSourceProvider at the minimum, other classes may be needed depending on what you want to do.

Related

Authorization in Helidon MP

Helidon uses annotations like
#RoleValidator.Roles({“my_admins”, “test”})
to do the authorization.
I am wondering if there is a way to do authorization differently using configuration settings for paths, for example.
Basically, the question is.
Is there a way to use configuration instead of annotation to authorize requests to particular endpoints?
If yes, would it be possible to get the SecurityContext like in a case of annotation?
Example with multiple roles for one endpoint would be helpful
I am successfully using annotations but in some cases it is not convenient
You should be able to do what you want using configuration instead of annotations. It would look similar to what our documentation describes here: https://helidon.io/docs/latest/index.html#/se/guides/security-oidc#Restrict-access-to-a-specific-role
You might not even use the annotations given your use case.
You would define the user-to-roles mapping however makes sense for you (Helidon config would work as would some other provider) and then use Helidon config to set up each endpoint's roles-allowed setting as needed.
As you are using Helidon MP, you could for example add something like this to your META-INF/microprofile-config.properties file:
web-server.paths.0.path=/greet
web-server.paths.0.methods=get
web-server.paths.0.roles-allowed=admin,dev
web-server.paths.0.authenticate=true
(These particular settings are drawn from Helidon's MP QuickStart example but you get the idea.)

RabbitMQ custom table source and sink for pyflink 1.11

According to the docs here:
https://ci.apache.org/projects/flink/flink-docs-release-1.11/dev/table/connectors/
and
https://ci.apache.org/projects/flink/flink-docs-release-1.11/dev/table/connectors/
is it possible to create a custom ddl RabbitMQ connector to be used in pyflink TABLE API 1.11?
how?
Firstly, you need to implement your custom connector implementation based on the interface provided by Java. Then you need to use the API or command line parameters to refer to the jar used which you can refer to
https://ci.apache.org/projects/flink/flink-docs-release-1.11/dev/table/python/common_questions.html#adding-jar-files

Spring Auto REST Docs + Spring Data REST? HATEOAS?

I really like the idea of using Javadoc comments for auto-generating REST Docs!
Huge parts of our REST API are automatically generated by Spring Data REST (by adding #RepositoryRestResource to Repositories). It would be great if REST Docs could also be generated for these - that would be a very high degree of automatition.
But unfortunately most "auto-"snippets are "empty" (e.g. auto-response-fields.adoc only contains a list of links[]-Attributes). I guess the reason could be that the REST Controllers are probably created dynamically by Spring Data REST. Currently I do not see how to re-use the Javadoc comments for them.
Is there any way to auto-generate REST Docs for such REST APIs that are provided by Spring Data REST?
It would even be helpful to manually tell Spring Auto REST Docs which classes are used in requests and responses instead of letting it discover it statically - is that possible?
And we also add HATEOAS "_links" to most response Resources (by providing ResourceProcessors as Beans). These links contain "title"s which are used by Spring REST Docs - if we list all of them with HypermediaDocumentation.linkWithRel(...). This is a bit redundant, and it would be nice if all the _links with "title"s could be processed automatically. (But this can be done by listing all of them in some extra code, so it is not as bad as with Spring Data REST.)
If necessary, I could also create an example project for what I am talking about.
Answer to the question whether one can manually tell Spring Auto REST Docs which classes to use for the documentation:
Spring Auto REST Docs allows to specify the request and response classes to use for the documentation. This can be done with requestBodyAsType and responseBodyAsType. In a test it looks like this:
.andDo(document("folderName",
requestFields().requestBodyAsType(Command.class),
responseFields().responseBodyAsType(CommandResult.class)));
This is from a test in the example project.

Geode SecurityManager implementation

I am currently lost on the requirement to implement a SecurityManager interface in Java / Geode per Implementing Authentication.
Is there standard implementation that I can point to in gemfire.properties to handle the security-username and security-password properties?
I got as far as taking the ExampleSecurityManager java class and saving it to the Geode bin directory, and then trying to point the security-manager property to it.
security-manager=org.apache.geode.security.examples.ExampleSecurityManager
If I run Geode out of the box and do exactly that then the locator fails to start with org.apache.geode.security.GemFireSecurityException: Instance could not be obtained, java.lang.ClassNotFoundException: org.apache.geode.security.examples.ExampleSecurityManager
A crazy question. THANKS for your comment.
#JensD thanks once again. I requested to update the Javadoc but the Custom Security Manager page has it the right way around!
It should be org.apache.geode.examples.security.ExampleSecurityManager

How can I cosume a GET REST call and mapping to a java bean (object) through Apache Camel?

I am new in apache camel. I want to do a GET REST call to get data and then I want to mapping these data to my Java bean. How can I do that with camel? I want to do it in a spring MVC web application.
I know how to do it with RestTemplate for example, but I want to use apache camel.
I've checked this documentation http://camel.apache.org/cxfrs.html but still I don't know how to set up for accomplishing this.
Please if you can provide some examples will be great.
There are a few different options. I'll walk through one...
First, define your rest configuration with bindingMode=auto
restConfiguration()
.component("jetty").host("0.0.0.0").port(9000)
.bindingMode(RestBindingMode.auto);
Next, when you define your particular rest service, specify a type (this is the type of the incoming body:
rest("/")
.put("/A/{subpath1}/{subpath2}")
.type(MyPojo.class)
.to("direct:XYZ");
That's it! The unmarshalling will be magical ;)
Alternatively, you can unmarshal things yourself.
If you'd like to see a working example of the above, check out this program: it has a main() to test it. https://github.com/DariusX/CamelSandbox/blob/master/CamelSandbox/src/main/java/com/zerses/camelsandbox/rest/RestConsumerBindingTest.java