Member since
08-19-2017
9
Posts
0
Kudos Received
1
Solution
My Accepted Solutions
Title | Views | Posted |
---|---|---|
1396 | 09-14-2017 08:53 PM |
10-12-2017
03:59 PM
I'm trying to write a java program that takes the XML file generated by a nifi-api url and generates an email if the queue size of the nifi flow exceeds a certain threshold. But the problem is that since SSL is enabled, the XML file is not being accessed and it gives me the below error: java.net.SocketException: Unexpected end of file from server at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:851) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678) at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:848) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1569) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474) at java.net.URL.openStream(URL.java:1045) at ReadXMLFile.main(ReadXMLFile.java:21) When I manually try to access the link I had to select a certificate and I think that is the problem in accessing the XML file from code. Can someone tell me how to sign or select a certificate through java code? My Program: import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;
import java.io.InputStream;
import java.net.URL;
public class ReadXMLFile {
public static void main(String argv[]) {
try {
URL url = new URL("https://172.22.2.6:9079/nifi-api/controller/process-groups/root/status?recursive=true");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
InputStream stream = url.openStream();
Document doc = dBuilder.parse(stream);
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList nList = doc.getElementsByTagName("processGroupStatus");
System.out.println("----------------------------");
for (int temp = 0; temp < nList.getLength(); temp++) {
System.out.println(nList.getLength());
Node nNode = nList.item(temp);
System.out.println("\nCurrent Element :" + nNode.getNodeName());
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
int lastElement = eElement.getElementsByTagName("queuedSize").getLength() -1;
System.out.println("queuedSize : " + eElement.getElementsByTagName("queuedSize").item(lastElement).getTextContent());
System.out.println("queuedCount : " + eElement.getElementsByTagName("queuedCount").item(lastElement).getTextContent());
}
}
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
... View more
Labels:
- Labels:
-
Apache NiFi
10-02-2017
04:10 PM
Hi, I am trying to figure out a way to do the equivalent of below command in phoenix: update ics_tag_list set targetColumn = concat( 'prefix', sourceColumn) where rig =somerig; I know that Phoenix does not support update command to update rows. But how do I update rows without entering values of all the columns in the query as an upsert command? Even with the upsert select command, we can only select values from other tables but I am not able to think of a way to generate the equivalent of above query in Phoenix since my source and target columns will change upon selection in the UI.
... View more
Labels:
- Labels:
-
Apache Phoenix
10-01-2017
05:42 PM
@mqureshi I tried using the consumer.position(TopicPartition partition) method. But this does not seem to give the correct value either. I know how to get them in the command line. So i am comparing the values in zookeeper to the one in java method. My goal is to get those values in Java.
... View more
09-30-2017
09:04 PM
Hi, I am trying to write a java program that monitors the kafka consumer and end offset values and send alerts if it does not update for a given period of time. So i was using the consumer.getCommitedOffsets() method in the Kafka consumer API in java. But this does not seem to be the correct consumer offset value or maybe not the consumer offset for this consumer group. Can anyone tell me how to get the value of consumer offsets in kafka for a consumer group and particular topic?
... View more
Labels:
- Labels:
-
Apache Kafka
09-18-2017
03:24 PM
I had written a program to extract data from phoenix and display it on a web page. Now i am trying to add the xml files(hbase-site,hdfs-site,core-site) dynamically into the jar by copying it from the server whenever i run it. Does anyone know how to do this?
... View more
Labels:
- Labels:
-
Apache HBase
-
Apache Phoenix
09-14-2017
08:53 PM
I got this fixed. Had to add a dependency for netty-all in the pom file.
... View more
09-14-2017
03:58 PM
I am including phoenix, hbase and zookeeper jars in the project. I have placed the configuration xml files (hbase-site.xml, core-site.xml and hdfs-site.xml) in the src directory(also tried src/main/resources) where all the java files are. This worked for me in a simple java project, but i am unable to make it hit the config files in a spring boot project. Can anyone help? [Request processing failed; nested exception is java.sql.SQLException: ERROR 103 (08004): Unable to establish connection.] with root cause java.lang.ClassNotFoundException: io.netty.channel.EventLoopGroup at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_131] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_131] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) ~[na:1.8.0_131] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_131] at java.lang.Class.forName0(Native Method) ~[na:1.8.0_131] at java.lang.Class.forName(Class.java:348) ~[na:1.8.0_131] at org.apache.hadoop.conf.Configuration.getClassByNameOrNull(Configuration.java:2180) ~[Table-0.0.1-SNAPSHOT.jar:0.0.1 public Connection connect() throws SQLException, ClassNotFoundException {
Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
Connection con = DriverManager.getConnection("jdbc:phoenix:172.22.2.77,172.22.2.79,172.22.2.80:2181:/hbase-secure:rowanadmin@ROWANHADOOP.NET:/home/rowanadmin/rowanadmin.keytab");
System.out.println("success");
return con;
}
... View more
Labels:
- Labels:
-
Apache HBase
-
Apache Phoenix
08-22-2017
05:24 PM
@Jay SenSharma Is it possible to connect to phoenix on server from local machine?
... View more
08-22-2017
04:01 PM
I have tried the below sample code from Phoenix website by copying the phoenix client jar from /usr/hdp/current/phoenix-client in my server. I tried running it locally as well as on the server, but i keep getting the below error: Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:phoenix:zk1,zk2,zk3:2181:/hbase-unsecure Are there any other prerequisites other than including the client jar in the code to connect to phoenix? PS: I had no problems connecting to phoenix from command line. import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
public class test {
public static void main(String[] args) throws SQLException {
Statement stmt = null;
ResultSet rset = null;
Connection con = DriverManager.getConnection("jdbc:phoenix:zk1,zk2,zk3:2181:/hbase-unsecure");
stmt = con.createStatement();
stmt.executeUpdate("create table test (mykey integer not null primary key, mycolumn varchar)");
stmt.executeUpdate("upsert into test values (1,'Hello')");
stmt.executeUpdate("upsert into test values (2,'World!')");
con.commit();
PreparedStatement statement = con.prepareStatement("select * from test");
rset = statement.executeQuery();
while (rset.next()) {
System.out.println(rset.getString("mycolumn"));
}
statement.close();
con.close();
}
}
... View more
Labels:
- Labels:
-
Apache Phoenix