Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "BUG 2820 - LLDP refactor"
[controller.git]
/
opendaylight
/
md-sal
/
sal-dom-xsql
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
md
/
sal
/
dom
/
xsql
/
XSQLAdapter.java
diff --git
a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java
b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java
index beab6d2fb1a0014e3dece9b1c07f77aa611ee090..05f65225eaec15755b520bf1f00e44038416e849 100644
(file)
--- a/
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java
+++ b/
opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLAdapter.java
@@
-1,3
+1,10
@@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.controller.md.sal.dom.xsql;
import java.io.File;
package org.opendaylight.controller.md.sal.dom.xsql;
import java.io.File;
@@
-24,12
+31,16
@@
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
-
+/**
+ * @author Sharon Aicler(saichler@gmail.com)
+ **/
public class XSQLAdapter extends Thread implements SchemaContextListener {
private static final int SLEEP = 10000;
private static XSQLAdapter a = new XSQLAdapter();
private static PrintStream l = null;
public class XSQLAdapter extends Thread implements SchemaContextListener {
private static final int SLEEP = 10000;
private static XSQLAdapter a = new XSQLAdapter();
private static PrintStream l = null;
+ private static String tmpDir = null;
+ private static File xqlLog = null;
public boolean stopped = false;
private List<String> elementHosts = new ArrayList<String>();
private String username;
public boolean stopped = false;
private List<String> elementHosts = new ArrayList<String>();
private String username;
@@
-49,6
+60,7
@@
public class XSQLAdapter extends Thread implements SchemaContextListener {
private String pinningFile;
private ServerSocket serverSocket = null;
private DOMDataBroker domDataBroker = null;
private String pinningFile;
private ServerSocket serverSocket = null;
private DOMDataBroker domDataBroker = null;
+ private static final String REFERENCE_FIELD_NAME = "reference";
private XSQLAdapter() {
XSQLAdapter.log("Starting Adapter");
private XSQLAdapter() {
XSQLAdapter.log("Starting Adapter");
@@
-79,6
+91,12
@@
public class XSQLAdapter extends Thread implements SchemaContextListener {
return a;
}
return a;
}
+ public static File getXQLLogfile() {
+ tmpDir = System.getProperty("java.io.tmpdir");
+ xqlLog = new File(tmpDir + "/xql.log");
+ return xqlLog;
+ }
+
public static void main(String args[]) {
XSQLAdapter adapter = new XSQLAdapter();
adapter.start();
public static void main(String args[]) {
XSQLAdapter adapter = new XSQLAdapter();
adapter.start();
@@
-90,7
+108,7
@@
public class XSQLAdapter extends Thread implements SchemaContextListener {
synchronized (XSQLAdapter.class) {
if (l == null) {
l = new PrintStream(
synchronized (XSQLAdapter.class) {
if (l == null) {
l = new PrintStream(
- new FileOutputStream(
"/tmp/xql.log"
));
+ new FileOutputStream(
getXQLLogfile()
));
}
}
}
}
}
}
@@
-108,7
+126,7
@@
public class XSQLAdapter extends Thread implements SchemaContextListener {
synchronized (XSQLAdapter.class) {
if (l == null) {
l = new PrintStream(
synchronized (XSQLAdapter.class) {
if (l == null) {
l = new PrintStream(
- new FileOutputStream(
"/tmp/xql.log"
));
+ new FileOutputStream(
getXQLLogfile()
));
}
}
}
}
}
}
@@
-144,27
+162,18
@@
public class XSQLAdapter extends Thread implements SchemaContextListener {
List<Object> result = new LinkedList<Object>();
YangInstanceIdentifier instanceIdentifier = YangInstanceIdentifier
.builder()
List<Object> result = new LinkedList<Object>();
YangInstanceIdentifier instanceIdentifier = YangInstanceIdentifier
.builder()
- .node(XSQLODLUtils.getPath(table.get
ODLNode
()).get(0))
+ .node(XSQLODLUtils.getPath(table.get
FirstFromSchemaNodes
()).get(0))
.toInstance();
DOMDataReadTransaction t = this.domDataBroker
.newReadOnlyTransaction();
Object node = t.read(type,
instanceIdentifier).get();
.toInstance();
DOMDataReadTransaction t = this.domDataBroker
.newReadOnlyTransaction();
Object node = t.read(type,
instanceIdentifier).get();
- node = XSQLODLUtils.get(node,
"reference"
);
+ node = XSQLODLUtils.get(node,
REFERENCE_FIELD_NAME
);
if (node == null) {
return result;
}
if (node == null) {
return result;
}
-
- // XSQLAdapter.log(""+node);
- Map<?, ?> children = XSQLODLUtils.getChildren(node);
- for (Object c : children.values()) {
- Map<?, ?> sons = XSQLODLUtils.getChildren(c);
- for (Object child : sons.values()) {
- result.add(child);
- }
- }
-
+ result.add(node);
return result;
} catch (Exception err) {
XSQLAdapter.log(err);
return result;
} catch (Exception err) {
XSQLAdapter.log(err);
@@
-341,7
+350,7
@@
public class XSQLAdapter extends Thread implements SchemaContextListener {
JDBCResultSet rs = new JDBCResultSet(sql);
try {
int count = 0;
JDBCResultSet rs = new JDBCResultSet(sql);
try {
int count = 0;
-
jdbc
Server.execute(rs, this);
+
JDBC
Server.execute(rs, this);
boolean isFirst = true;
int loc = rs.getFields().size() - 1;
int totalWidth = 0;
boolean isFirst = true;
int loc = rs.getFields().size() - 1;
int totalWidth = 0;