Geode SecurityManager implementation - gemfire

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

Related

Using selection strategies with a cache in Curator

The page on Service Discovery using apache curator (https://github.com/Netflix/curator/wiki/Service-Discovery) introduces the following concepts:
The main abstraction class is ServiceProvider. It encapsulates the discovery service for a particular named service along with a provider strategy. A provider strategy is a scheme for selecting one instance from a set of instances for a given service. There are three bundled strategies: Round Robin, Random and Sticky (always selects the same one). ServiceProviders are allocated by using a ServiceProviderBuilder.
Each of the above query methods calls ZooKeeper directly. If you need more than occasional querying of services you can use the ServiceCache. It caches in memory the list of instances for a particular service. It uses a Watcher to keep the list up to date. You allocate a ServiceCache via the builder returned by ServiceDiscovery.serviceCacheBuilder().
I can see how to use the Provider strategies with a ServiceProviderBuilder, but there's no equivalent method on the ServiceCacheBuilder, and the only relevant method available on the ServiceCache class itself is getInstances(), which gets all instances.
How can I use a provider strategy with a ServiceCache?
#simonalexander2005 I was just looking in the code and it turns out that ServiceProvider internally already uses a serviceCacheBuilder. TBH - I've either forgotten about this or it got put in by another committer - I'm not sure. Anyway, I'm very sorry about the runaround here. Also, the documentation must be updated to reflect this - I'll open an issue for this today. I'm sure this be maddening to you, again sorry for this. The good news, though, is that with ServiceProvider you automatically get caching.
Frankly, the docs on this are really bad. It would be fantastic if someone could give a pull request with better docs...
Notice that ServiceCache implements InstanceProvider. Also notice that ProviderStrategy.getInstance() has as its argument InstanceProvider. Therefore, you can pass a ServiceCache instance to whichever ProviderStrategy you want to use.
I hope this helps.

Java - is bytebuddy agent capable of "Fully" redefine a class?

Is byte-buddy agent capable of overcoming Attach API restrictions e.g. "new method definition", "static variable changes" ? I can see that redefineClasses method is being called from Agent Builder, but not sure if this is also following the same restrictions as the attach API.
I am trying to understand whether I can do the following:
1) Load the agent jar using an application class loader e.g. ParallelWebappClassLoader. My application is a servlet webapp and during runtime it uses the above classloader to load all application classes.
2) Fully redefine my classes i.e. any method addition/updates and static/local variable changes/updates/addition.
I do have an agent which currently works within the Attach API restrictions, but I am struggling to delegate the class loading from System Class Loader to application.
Many Thanks,
This is a restriction of the Java virtual machine you are running. Byte Buddy is capable of "fully redefining" a class by using its API but most VMs will reject such changes. Have a look at the dynamic code evolution VM for being able to apply such changes.

How to write custom connector for Facebook Presto?

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.

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

Mule spring bean schedule run

We have defined spring beans in Mule-config.xml. Certain public methods in this bean class needs to be periodically executed. We attempted to used spring quartz and spring task scheduler (adding beans in mule-config.xml)- but method is not executing in a schedule way - it is not triggered. Even using annotation (scheduled) does not work. Any work around for this? Any issue with spring scheduler with mule? Kindly help.
Thanks
If you want to use the Schedule annotation, take a look at this recent answer on the subject for a workaround.
Otherwise, Spring Quartz should work fine too. What have you tried? Share your config and specify the Mule version you're using. I'll review my answer accordingly.