Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
7c80aba2
Commit
7c80aba2
authored
Jan 17, 2018
by
Graham Wallis
Committed by
Sarath Subramanian
Jan 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2370: Fix LocalSolrRunner path issue in Windows
Signed-off-by:
Sarath Subramanian
<
ssubramanian@hortonworks.com
>
parent
72030ad1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
LocalSolrRunner.java
...rc/main/java/org/apache/atlas/runner/LocalSolrRunner.java
+16
-9
No files found.
test-tools/src/main/java/org/apache/atlas/runner/LocalSolrRunner.java
View file @
7c80aba2
...
@@ -36,11 +36,12 @@ import java.util.regex.Pattern;
...
@@ -36,11 +36,12 @@ import java.util.regex.Pattern;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
public
class
LocalSolrRunner
{
public
class
LocalSolrRunner
{
protected
static
final
String
[]
COLLECTIONS
=
readCollections
();
private
static
final
String
TARGET_DIRECTORY
=
System
.
getProperty
(
"embedded.solr.directory"
);
private
static
final
String
TARGET_DIRECTORY
=
System
.
getProperty
(
"embedded.solr.directory"
);
private
static
final
String
COLLECTIONS_FILE
=
"collections.txt"
;
private
static
final
String
COLLECTIONS_FILE
=
"collections.txt"
;
private
static
final
String
SOLR_XML
=
"solr.xml"
;
private
static
final
String
SOLR_XML
=
"solr.xml"
;
private
static
final
String
TEMPLATE_DIRECTORY
=
"core-template"
;
private
static
final
String
TEMPLATE_DIRECTORY
=
"core-template"
;
protected
static
final
String
[]
COLLECTIONS
=
readCollections
();
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
LocalSolrRunner
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
LocalSolrRunner
.
class
);
...
@@ -105,16 +106,26 @@ public class LocalSolrRunner {
...
@@ -105,16 +106,26 @@ public class LocalSolrRunner {
}
}
private
static
String
[]
readCollections
()
{
private
static
String
[]
readCollections
()
{
try
(
InputStream
inputStream
=
LocalSolrRunner
.
class
.
getResourceAsStream
(
"/solr"
+
File
.
separator
+
COLLECTIONS_FILE
);
// For the classloader you need the following path: "/solr/collections.txt";
BufferedReader
buffer
=
new
BufferedReader
(
new
InputStreamReader
(
inputStream
)))
{
// Use explicit '/' separators (not File.separator) because even on Windows you want '/'
String
resName
=
"/solr/"
+
COLLECTIONS_FILE
;
try
{
InputStream
inputStream
=
LocalSolrRunner
.
class
.
getResourceAsStream
(
resName
);
InputStreamReader
isr
=
new
InputStreamReader
(
inputStream
);
BufferedReader
buffer
=
new
BufferedReader
(
isr
);
return
Pattern
.
compile
(
"\\s+"
).
split
(
buffer
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
)));
return
Pattern
.
compile
(
"\\s+"
).
split
(
buffer
.
lines
().
collect
(
Collectors
.
joining
(
"\n"
)));
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Unable to read collections file"
,
e
);
throw
new
RuntimeException
(
"Unable to read collections file"
,
e
);
}
}
}
}
private
static
String
readSolrXml
()
throws
IOException
{
private
static
String
readSolrXml
()
throws
IOException
{
InputStream
inputStream
=
getClassLoader
().
getResourceAsStream
(
"solr"
+
File
.
separator
+
SOLR_XML
);
// For the classloader you need the following path: "/solr/solr.xml";
// Use explicit '/' separators (not File.separator) because even on Windows you want '/'
String
resName
=
"/solr/"
+
SOLR_XML
;
// Use the local classloader rather than the system classloader - i.e. avoid using
// Thread.currentThread().getContextClassLoader().getResourceAsStream(resName);
InputStream
inputStream
=
LocalSolrRunner
.
class
.
getResourceAsStream
(
resName
);
if
(
inputStream
==
null
)
{
if
(
inputStream
==
null
)
{
throw
new
RuntimeException
(
"Unable to read solr xml"
);
throw
new
RuntimeException
(
"Unable to read solr xml"
);
...
@@ -123,10 +134,6 @@ public class LocalSolrRunner {
...
@@ -123,10 +134,6 @@ public class LocalSolrRunner {
return
IOUtils
.
toString
(
inputStream
,
Charset
.
forName
(
"UTF-8"
));
return
IOUtils
.
toString
(
inputStream
,
Charset
.
forName
(
"UTF-8"
));
}
}
private
static
ClassLoader
getClassLoader
()
{
return
Thread
.
currentThread
().
getContextClassLoader
();
}
private
static
String
getRandomString
()
{
private
static
String
getRandomString
()
{
return
UUID
.
randomUUID
().
toString
();
return
UUID
.
randomUUID
().
toString
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment