Error while creating cluster using MiniSolrCloudCluster - junit

We were using solr6.2 version, and we are migrating it to latest solr8.2 version now. ALl our test cases are failing while creating the cluster. We are using MiniSolrCloudCluster to create a cluster, but it internally uses JettySolrRunner class where few methods and classes are deprecated. Because of this, we are getting the following error:
Java.lang.Exception: Error starting up MiniSolrCloudCluster
at org.apache.solr.cloud.MiniSolrCloudCluster.checkForExceptions(MiniSolrCloudCluster.java:652)
at org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:306)
at org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:239)
at org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:219)
at org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:146)
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Suppressed: java.lang.NoSuchMethodError: org.eclipse.jetty.util.thread.QueuedThreadPool.setReservedThreads(I)V
at org.apache.solr.client.solrj.embedded.JettySolrRunner.init(JettySolrRunner.java:265)
at org.apache.solr.client.solrj.embedded.JettySolrRunner.(JettySolrRunner.java:257)
at org.apache.solr.client.solrj.embedded.JettySolrRunner.(JettySolrRunner.java:229)
at org.apache.solr.client.solrj.embedded.JettySolrRunner.(JettySolrRunner.java:216)
at org.apache.solr.cloud.MiniSolrCloudCluster.startJettySolrRunner(MiniSolrCloudCluster.java:465)
at org.apache.solr.cloud.MiniSolrCloudCluster.lambda$new$0(MiniSolrCloudCluster.java:300)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0(ExecutorUtil.java:209)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
... 1 more
public MiniSolrCloudCluster cluster() throws Exception {
JettyConfig jettyConfig = JettyConfig.builder().setContext("/").build();
return new MiniSolrCloudCluster(3, Paths.get("build/cluster"), jettyConfig);
}
Please suggest if there is any way to create solr cluster using solr-core-8.2.0

You can try to create solr cluster as I did.
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.JettyConfig;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.List;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.response.ConfigSetAdminResponse;
import org.apache.solr.cloud.MiniSolrCloudCluster;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
public class MiniSolrCloudClusterUtil {
private MiniSolrCloudCluster miniSolrCloudCluster;
public MiniSolrCloudClusterUtil(String fileLoc, int numServers) {
Path baseDir = (new File(fileLoc)).toPath();
JettyConfig jettyConfig = JettyConfig.builder().setPort(0).build();
try {
this.miniSolrCloudCluster = new MiniSolrCloudCluster(numServers, baseDir, jettyConfig);
} catch (Exception var6) {
throw new IllegalArgumentException("MiniSolrCloudCluster cannot be created. ", var6);
}
}
public MiniSolrCloudCluster getMiniSolrCloudCluster() {
return this.miniSolrCloudCluster;
}
public ConfigSetAdminResponse listConfigSets() {
try {
return (new List()).process(this.miniSolrCloudCluster.getSolrClient());
} catch (IOException | SolrServerException var2) {
throw new IllegalArgumentException("Unable to pull config set", var2);
}
}
public CollectionAdminResponse getSolrClusterStatus() {
try {
return CollectionAdminRequest.getClusterStatus().process(this.miniSolrCloudCluster.getSolrClient());
} catch (IOException | SolrServerException var2) {
throw new IllegalArgumentException("Unable to pull config set", var2);
}
}
}

Related

Logging of unit test result using AspectJ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm trying to log my test suite results using AspectJ. I'd like to 'inject' the results identification code after each #Test method in my code, so created an aspect with the following method:
#After("execution(* *(..)) && #annotation(org.junit.Test)")
public void afterTestMethod(JoinPoint joinPoint) {
//identify test result
}
However, can't find how to retrieve the test method result (passed/failed/skipped).
Any suggestions?
Thanks!
A) JUnit run listener
I am assuming that you build your project with something like Maven or Gradle and will show you a Maven example for a JUnit 4 RunListener:
In module test-tools you would add
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<!--
We build something with the JUnit API, not just run a test,
so scope 'test' is not enough here
-->
<scope>compile</scope>
</dependency>
to your POM and then have something like this in src/main/java/...:
package de.scrum_master.testing;
import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
public class ResultPrintingRunListener extends RunListener {
#Override
public void testRunStarted(Description description) {
System.out.println("[RunStarted] description = " + description);
}
#Override
public void testRunFinished(Result result) {
System.out.println("[RunFinished] result = " + result);
System.out.println(" run count = " + result.getRunCount());
System.out.println(" failure count = " + result.getFailureCount());
System.out.println(" assumption failure count = " + result.getAssumptionFailureCount());
System.out.println(" ignored count = " + result.getIgnoreCount());
System.out.println(" run time (ms) = " + result.getRunTime());
}
#Override
public void testSuiteStarted(Description description) {
System.out.println("[SuiteStarted] description = " + description);
}
#Override
public void testSuiteFinished(Description description) {
System.out.println("[SuiteFinished] description = " + description);
}
#Override
public void testStarted(Description description) {
System.out.println("[Started] description = " + description);
}
#Override
public void testFinished(Description description) {
System.out.println("[Finished] description = " + description);
}
#Override
public void testFailure(Failure failure) {
System.out.println("[Failure] failure = " + failure);
}
#Override
public void testAssumptionFailure(Failure failure) {
System.out.println("[AssumptionFailure] failure = " + failure);
}
#Override
public void testIgnored(Description description) {
System.out.println("[Ignored] description = " + description);
}
}
Instead of logging you would put your API calls in there at the appropriate places.
In your application test module you would add the test-tools module as a dependency and then configure your Maven Surefire/Failsafe plugins like this:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<properties>
<property>
<name>listener</name>
<value>de.scrum_master.testing.ResultPrintingRunListener</value>
</property>
</properties>
</configuration>
</plugin>
If then you run a test like this in Maven, ...
package de.scrum_master.agent.aspect;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
public class MyTest {
#Test
public void one() {
Assert.assertEquals("xander", "Alexander".substring(3));
}
#Test
public void two() {
Assert.assertEquals("Alex", "Alexander".substring(3));
}
#Test
public void three() {
Assert.assertEquals(11, 1 / 0);
}
#Test
#Ignore
public void four() {
Assert.assertNull(null);
}
}
... Maven prints:
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[RunStarted] description = null
[INFO] Running de.scrum_master.agent.aspect.MyTest
[SuiteStarted] description = de.scrum_master.agent.aspect.MyTest
[Started] description = one(de.scrum_master.agent.aspect.MyTest)
[Finished] description = one(de.scrum_master.agent.aspect.MyTest)
[Started] description = two(de.scrum_master.agent.aspect.MyTest)
[Failure] failure = two(de.scrum_master.agent.aspect.MyTest): expected:<[Alex]> but was:<[xander]>
[Finished] description = two(de.scrum_master.agent.aspect.MyTest)
[Ignored] description = four(de.scrum_master.agent.aspect.MyTest)
[Started] description = three(de.scrum_master.agent.aspect.MyTest)
[Failure] failure = three(de.scrum_master.agent.aspect.MyTest): / by zero
[Finished] description = three(de.scrum_master.agent.aspect.MyTest)
[SuiteFinished] description = de.scrum_master.agent.aspect.MyTest
[ERROR] Tests run: 4, Failures: 1, Errors: 1, Skipped: 1, Time elapsed: 0.11 s <<< FAILURE! - in de.scrum_master.agent.aspect.MyTest
[ERROR] de.scrum_master.agent.aspect.MyTest.two Time elapsed: 0.007 s <<< FAILURE!
org.junit.ComparisonFailure: expected:<[Alex]> but was:<[xander]>
at de.scrum_master.agent.aspect.MyTest.two(MyTest.java:31)
[ERROR] de.scrum_master.agent.aspect.MyTest.three Time elapsed: 0.001 s <<< ERROR!
java.lang.ArithmeticException: / by zero
at de.scrum_master.agent.aspect.MyTest.three(MyTest.java:36)
[RunFinished] result = org.junit.runner.Result#79be0360
run count = 3
failure count = 2
assumption failure count = 0
ignored count = 1
run time (ms) = 0
JUnit test watcher rule
If you prefer something which is independent of a specific JUnit runner right inside your tests, create a base class like this using JUnit TestWatcher:
package de.scrum_master.agent.aspect;
import org.junit.Rule;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
public class TestBase {
#Rule(order = Integer.MIN_VALUE)
public TestWatcher testWatcher = new TestWatcher() {
#Override
protected void failed(Throwable e, Description description) {
System.out.println("[TestWatcher failed] description = " + description +", e = " + e);
}
#Override
protected void succeeded(Description description) {
System.out.println("[TestWatcher succeeded] description = " + description);
}
};
}
Then make all your test classes extends TestBase directly or indirectly. If you run the test, e.g. from an IDE, you see (shortened output, only test watcher log):
[TestWatcher succeeded] description = one(de.scrum_master.agent.aspect.MyTest)
[TestWatcher failed] description = two(de.scrum_master.agent.aspect.MyTest), e = org.junit.ComparisonFailure: expected:<[Alex]> but was:<[xander]>
[TestWatcher failed] description = three(de.scrum_master.agent.aspect.MyTest), e = java.lang.ArithmeticException: / by zero
You see, there are fewer events in the test watcher, e.g. ignored tests are not reported.
As much as I love AspectJ (which is how I found this question), I think you should try configuring JUnit appropriately first and will probably be happy with it. If for whatever reason - please explain, if so - you still insist in an AOP solution, please let me know.
(C) Intercept JUnit tests directly
Because you insisted:
package de.scrum_master.aspectj;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
#Aspect
public class TestResultInterceptor {
#AfterReturning(value = "execution(* *(..)) && #annotation(org.junit.Test)", returning = "result")
public void allMethods(JoinPoint joinPoint, Object result) {
System.out.println(joinPoint + " -> PASSED");
}
#AfterThrowing(value = "execution(* *(..)) && #annotation(org.junit.Test)", throwing = "throwable")
public void allMethods(JoinPoint joinPoint, Throwable throwable) {
System.out.println(joinPoint + " -> FAILED: " + throwable);
}
}
When running the JUnit test above in my IDE, the console log is:
execution(void de.scrum_master.testing.MyTest.one()) -> PASSED
execution(void de.scrum_master.testing.MyTest.two()) -> FAILED: org.junit.ComparisonFailure: expected:<[Alex]> but was:<[xander]>
execution(void de.scrum_master.testing.MyTest.three()) -> FAILED: java.lang.ArithmeticException: / by zero
I think you can take it from here.

How can I export my bookmarks and import them into a table?

I have hundreds of bookmarks that I have collected over the years that I would like to put into a searchable table with extra information such as categories, types, descriptions etc.
My first attempt at this was manually putting them into a JSON file and then using the DataTables plug-in to display them, however, this was tedious and time-consuming.
The second attempt was to use Wordpress and use Advanced Custom Fields to do this but again still quite tedious.
Obviously, I can export my bookmarks as an HTML file and I'm considering editing and styling this file to suit my needs but it is absolutely massive and also has loads of extraneous information. I've been trying to use CSV conversions of this file to import it into various Wordpress plug-ins that say they offer this exact functionality to know avail. I've also tried doing something similar with firefox's backup that exports to a JSON file but again no luck.
I know that I will have to manually put in some of the information, but I'm trying to cut down on the workload by about a third. Am I going about this the wrong way? Is it even possible? Just wondering if anyone out there has tried to do the same thing and how they went about it.
That was a lovely challenge, thanks. Basically, what I've done is saved the exported bookmarks as HTML and then created a simple page with an empty table. Then my JS does this:
$(function() {
var example = $("#example").DataTable({
"responsive": true,
"columns": [
{
"title": "Title",
"data": "text"
},{
"title": "Date added",
"data": "date",
"render": function(d){
return moment(d, "X").format("DD/MM/YYYY");
}
},{
"title": "URI",
"data": "href",
"render": function(d){
return $("<a></a>",{
"text": d,
"href": d
}).prop("outerHTML");
}
}
],
"initComplete": function(settings, json) {
$.get("bookmarks_12_2_16.html", function( data ) {
$(data).find("dl").children("dt").children("a").each(function(k, v){
if(!~~$(v).attr("href").indexOf("http")){
example.row.add({
"href": $(v).attr("href"),
"text": $(v).text(),
"date": $(v).attr("add_date")
});
}
});
example.draw();
});
}
});
});
Basically it gets the HTML and iterates over the dts within the dl and, if the href is http or https, it adds it to the table with the correct date (you'd date function might have to be different seeing as I'm in the UK and I'm using momentjs). Hope that helps.
You can parse exported file from chrome using below:
Here i have used SAX parser to parse and extract url and link from bookmark.
Below three classes will parse xml and print bookmark url title and link.
you can export it into csv or you can use it in better way to generate table dynamically from which you can search.
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
public class BookmarkReader {
public static void main(String argv[]) {
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
try {
xmlReader.setFeature(
"http://apache.org/xml/features/continue-after-fatal-error",
true);
} catch (SAXException e) {
System.out.println("error in setting up parser feature");
}
xmlReader.setContentHandler(new ContentHandler());
xmlReader.setErrorHandler(new MyErrorHandler());
xmlReader.parse("C:\\Users\\chetankumar.p\\Documents\\bookmarks_12_2_16.html");
} catch (Throwable e) {
System.out.println(e.getMessage());
}
}
}
import java.util.ArrayList;
import java.util.List;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class ContentHandler extends DefaultHandler {
class Bookmark {
public String title;
public String href;
}
Bookmark bookmark;
List<Bookmark> bookmarks = new ArrayList<>();
#Override
public void endDocument() throws SAXException {
for (Bookmark bookmark1 : bookmarks) {
System.out.println("title : " + bookmark1.title);
System.out.println("title : " + bookmark1.href);
}
}
#Override
public void startElement(String uri, String localName,
String qName, Attributes attributes)
throws SAXException {
if (qName.equalsIgnoreCase("a")) {
bookmark = new Bookmark();
System.out.println("href ::: " + attributes.getValue("HREF"));
bookmark.href = attributes.getValue("HREF");
}
}
#Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.equalsIgnoreCase("a")) {
bookmarks.add(bookmark);
bookmark = null;
}
}
#Override
public void characters(char[] ch, int start, int length) throws SAXException {
if (bookmark != null) {
bookmark.title = new String(ch, start, length);
}
}
}
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class MyErrorHandler implements ErrorHandler {
private String getParseExceptionInfo(SAXParseException spe) {
String systemId = spe.getSystemId();
if (systemId == null) {
systemId = "null";
}
String info = "URI=" + systemId + " Line="
+ spe.getLineNumber() + ": " + spe.getMessage();
return info;
}
public void warning(SAXParseException spe) throws SAXException {
System.out.println("Warning: " + getParseExceptionInfo(spe));
}
public void error(SAXParseException spe) throws SAXException {
String message = "Error: " + getParseExceptionInfo(spe);
System.out.println(message);
}
public void fatalError(SAXParseException spe) throws SAXException {
String message = "Fatal Error: " + getParseExceptionInfo(spe);
System.out.println(message);
}
}
Firefox Bookmarks to .xlsm [SOLVED]
I figured out how to get my bookmarks out of Firefox and into Excel. A macro processes them, and other macros get you around the Worksheet.
It uses: 1.) Firefox, 2.) SQLite3, 3.) DOS, 4.) Excel VBA, 5.) NirCmd (optional)
All you have to do is to categorize your bookmarks, and then click the sort button.
These two PDFs provide code for the BAT files, and explain how to set up the paths for the macros. More instructions are in the VBA of the xlsm. These three files are on my Google Docs.
I thought I'd share this, because it's cool, might be useful to others . . . and maybe someone can improve on what I have, or give me some more ideas . . . maybe this post can be left open.
bookmarks-to-CSV.pdf . . . This first page provides all you need to know, to get your Bookmarks into a .CSV file (This won't do anything to your actual Bookmarks, it just extracts a copy of them.) . . . Then, the next few pages provide the details of what's going on . . . https://drive.google.com/open?id=1xYWPQtijqCzk-1nzTsTb0ZUVKYJNFokR
Custom UI Editor.pdf . . . Supporting info, and BAT file code to be set up . . . https://drive.google.com/open?id=1G2AWBamOrbAo2ZNDtUyYdzegjKzz34DA
bookmarks-p.xlsm . . . The Preview on Google Docs isn't that great. Some supporting info is in the first four Worksheets. Bookmarks are in the fifth Worksheet (see tabs across the bottom) . . . https://drive.google.com/open?id=1ZOuOBkdJjMx1T4xMUNG7sf6MDWurUqqy
Use extensions on the Chrome Store to generate a JSON/CSV output. Converting that to table form should be fairly straightforward.
Bookmarks to JSON/CSV (including chrome history)
Bookmarks to
JSON (root or folder based)
Bookmarks Table (view only, by date)

Cannot retrieve document from couchbase lite when adding documents to couchbase server using admin UI

I am trying to add documents to couchbase server(admin UI) and then trying to retrieve it using couchbase Lite via sync gateway but unable to do so. What I am trying to achieve is I already have a lot of data in couchbase server now I want my mobile app to use it and because that data was not added using sync gateway I want to achieve something like I added data using web now I want my couchbase lite to connect to that couchbase server and retrieve data. Is there any way to do it? or only data that has been added using sync gateway can be retrieved?
EDIT 1 Added Source Codes
Below is the android app code
package com.couchbase.examples.couchbaseevents;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import com.couchbase.lite.CouchbaseLiteException;
import com.couchbase.lite.Database;
import com.couchbase.lite.Document;
import com.couchbase.lite.Manager;
import com.couchbase.lite.android.AndroidContext;
import com.couchbase.lite.replicator.Replication;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
public static final String DB_NAME = "couchbaseevents";
final String TAG = "CouchbaseEvents";
Database database = null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d(TAG, "Begin Couchbase Events App");
Manager manager = null;
try {
manager = new Manager(new AndroidContext(this), Manager.DEFAULT_OPTIONS);
database = manager.getDatabase(DB_NAME);
} catch (Exception e) {
Log.d(TAG, "Error getting database", e);
return;
}
/*try {
database.delete();
} catch (Exception e) {
Log.e(TAG, "Cannot delete database", e);
return;
}*/
try {
startReplications();
} catch (CouchbaseLiteException e) {
e.printStackTrace();
}
Document retrievedDocument = database.getDocument("123");
// display the retrieved document
Log.d(TAG, "retrievedDocument=" + String.valueOf(retrievedDocument.getProperties()));
Log.d(TAG, "End Couchbase Events App");
}
private URL createSyncURL(boolean isEncrypted){
URL syncURL = null;
String host = "http://172.16.25.100";
String port = "4986";
String dbName = "sync_gateway";
try {
//syncURL = new URL("http://127.0.0.1 :4986/sync_gateway");
syncURL = new URL(host + ":" + port + "/" + dbName);
} catch (Exception me) {
me.printStackTrace();
}
Log.d(syncURL.toString(),"URL");
return syncURL;
}
private void startReplications() throws CouchbaseLiteException {
Replication pull = database.createPullReplication(this.createSyncURL(false));
Replication push = database.createPushReplication(this.createSyncURL(false));
pull.setContinuous(true);
push.setContinuous(true);
pull.start();
push.start();
if(!push.isRunning()){
Log.d(TAG, "MyBad");
}
/*if(!push.isRunning()) {
Log.d(TAG, "Replication is not running due to " +push.getLastError().getMessage());
Log.d(TAG, "Replication is not running due to " +push.getLastError().getCause());
Log.d(TAG, "Replication is not running due to " +push.getLastError().getStackTrace());
Log.d(TAG, "Replication is not running due to " +push.getLastError().toString());
}*/
}
}
"123" is the document id of document I created in CouchBase server using admin UI
As you can see I first deleted the database( commented part) to make sure there is no document in database and then ran the above replication code.
Below is the sync gateway config file
{
"log":["CRUD+", "REST+", "Changes+", "Attach+"],
"interface":":4986",
"adminInterface":":14985",
"databases": {
"sync_gateway": {
"server":"http://172.16.25.100:8091",
"bucket":"sync_gateway",
"sync":`
function (doc) {
channel (doc.channels);
}`,
"users": {
"GUEST": {
"disabled": false,
"admin_channels": ["*"]
}
}
}
}
}
I also want to ask is there any UI or command line to access CBL. I am currently using CBL in android studio so I dont know how to access its UI or command line
Just for the information, I am able to push data from CBL to CouchBase server
We can solve the above issue by shadowing. If I want to sync my data from the already made bucket to sync gateway bucket shadowing is required. More about Shadowing here

Apache Drill - DrillStartupException with CustomAuthenticaor

I tried creating a custom authenticator with Drill 1.5.0 by creating jar based on below source code and drill configuration. I placed the jar in $DRILLHOME/jars/
drill-override.conf File :
drill.exec: {
cluster-id: "drillbits1",
zk.connect: "host1:2181,host2:2181,host3:2181"
security.user.auth: {
enabled: true,
packages += “myorg.drill.security",
impl: “sso"
}
}
DrillMyUserAuthenticator Class:
package myorg.drill.security;
import myorg.drill.security.SSOFilter;
import myorg.drill.security.SecurityServiceException;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.exec.exception.DrillbitStartupException;
import org.apache.drill.exec.rpc.user.security.UserAuthenticationException;
import org.apache.drill.exec.rpc.user.security.UserAuthenticator;
import org.apache.drill.exec.rpc.user.security.UserAuthenticatorTemplate;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
#UserAuthenticatorTemplate(type = “sso")
public class DrillMyUserAuthenticator implements UserAuthenticator {
private String ipAddress;
public void setup(DrillConfig drillConfig) throws DrillbitStartupException {
try {
ipAddress= InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
e.printStackTrace();
throw new DrillbitStartupException(e);
}
}
public void authenticate(String userName, String password) throws UserAuthenticationException {
try {
SSOFilter.setSourceAddress(ipAddress);
SSOFilter.authenticate(userName, password);
} catch (SecurityServiceException e) {
e.printStackTrace();
throw new UserAuthenticationException(e.getMessage());
}
}
public void close() throws IOException {
}
}
And I am getting below exception:
exception in thread "main" org.apache.drill.exec.exception.DrillbitStartupException: Failure while initializing values in Drillbit.
at org.apache.drill.exec.server.Drillbit.start(Drillbit.java:277)
at org.apache.drill.exec.server.Drillbit.start(Drillbit.java:261)
at org.apache.drill.exec.server.Drillbit.main(Drillbit.java:257)
Caused by: org.apache.drill.exec.exception.DrillbitStartupException: Failed to find the implementation of 'org.apache.drill.exec.rpc.user.security.UserAuthenticator' for type ’sso'
at org.apache.drill.exec.rpc.user.security.UserAuthenticatorFactory.createAuthenticator(UserAuthenticatorFactory.java:103)
at org.apache.drill.exec.rpc.user.UserServer.(UserServer.java:80)
at org.apache.drill.exec.service.ServiceEngine.(ServiceEngine.java:79)
at org.apache.drill.exec.server.Drillbit.(Drillbit.java:89)
at org.apache.drill.exec.server.Drillbit.start(Drillbit.java:275)
Please let me know if I am missing something with the config or code.
I followed Drill's documentation to create this.
Turns out be a documentation issue on Drill Side. https://issues.apache.org/jira/browse/DRILL-4461
Above Jira has the solution to the problem.New jar for the custom authenticator should be created with drill-module.conf in order for the classpath scanner to pick it up
drill: {
classpath.scanning: {
packages: [
"myorg.drill.security"
]
}
}

Properties MySQL context

I am studying the tutorial javarevoltions JSF 2 + PrimeFaces 5 + 4 + Spring Hibernate 4.
Essse tutorial is based on weblogic server and Oracle database.
My problem is I want to use glassfish with MySQL instead.
There is a file called utilidades.java containing webologic properties.
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class Utilities {
public static Object getEJBRemote (nameEJB String, String iface) throws Exception {
Context context;
Properties props = new Properties ();
props.put (Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
props.put (Context.PROVIDER_URL, "http: // localhost: 7001");
try {
context = new InitialContext (props);
String lookup nameEJB + = "#" + iface;
System.out.println ("Lookup" + lookup);
return context.lookup (lookup);
} Catch (Exception ex) {
throw new Exception ("There is EJB: '" + nameEJB + "'.");
}
    }
}
I've changed to:
props.put (Context.INITIAL_CONTEXT_FACTORY, "org.springframework.jndi.JndiObjectFactoryBean");
props.put (Context.PROVIDER_URL, "http: // localhost: 4848");
This I saw a tutorial on the Internet, using glassfish and mysql. I created the ping successfully datasource in glassfish.
When I do a debbug it appears:
ex = (javax.naming.NoInitialContextException)
javax.naming.NoInitialContextException: Can not instantiate class:
org.springframework.jndi.JndiObjectFactoryBean [Root exception is
java.lang.ClassCastException:
org.springframework.jndi.JndiObjectFactoryBean can not be cast to
javax.naming .spi.InitialContextFactory]
What am I doing wrong?
Your problem is that weblogic.jndi.WLInitialContextFactory is not an InitialContextFactory. I think the value you want for Glassfish is com.sun.enterprise.naming.SerialInitContextFactory:
Properties props = new Properties ();
props.put (Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
props.put (Context.PROVIDER_URL, "http: // localhost: 7001");
This answer has more detail.