Skip to content

Commit 624e5ca

Browse files
committed
Add possibility to send created json file to docker
1 parent f68dff7 commit 624e5ca

File tree

19 files changed

+323
-35
lines changed

19 files changed

+323
-35
lines changed

org.sofproject.alsa.topo/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ Export-Package: org.sofproject.alsa.topo.conf,
1010
Require-Bundle: org.sofproject.core,
1111
org.sofproject.topo.ui
1212
Bundle-Vendor: Intel Corporation
13-
Import-Package: org.sofproject.gst.json
13+
Import-Package: org.sofproject.topo.ui.json

org.sofproject.gst.topo/.classpath

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
</accessrules>
77
</classpathentry>
88
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
9-
<classpathentry exported="true" kind="lib" path="lib/jackson-annotations-2.10.1.jar"/>
10-
<classpathentry exported="true" kind="lib" path="lib/jackson-core-2.10.1.jar"/>
11-
<classpathentry exported="true" kind="lib" path="lib/jackson-databind-2.10.1.jar"/>
129
<classpathentry kind="src" path="src"/>
13-
<classpathentry kind="lib" path="C:/Users/edominia/Downloads/jackson-annotations-2.10.1.jar" sourcepath="C:/Users/edominia/Downloads/jackson-annotations-master.zip"/>
14-
<classpathentry kind="lib" path="C:/Users/edominia/Downloads/jackson-core-2.10.1.jar" sourcepath="C:/Users/edominia/Downloads/jackson-core-master.zip"/>
15-
<classpathentry kind="lib" path="C:/Users/edominia/Downloads/jackson-databind-2.10.1.jar" sourcepath="C:/Users/edominia/Downloads/jackson-databind-master.zip"/>
1610
<classpathentry kind="output" path="bin"/>
1711
</classpath>

org.sofproject.gst.topo/META-INF/MANIFEST.MF

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,5 @@ Require-Bundle: org.sofproject.core,
1010
org.sofproject.ui,
1111
org.sofproject.topo.ui,
1212
com.jcraft.jsch
13-
Bundle-ClassPath: lib/jackson-annotations-2.10.1.jar,
14-
lib/jackson-core-2.10.1.jar,
15-
lib/jackson-databind-2.10.1.jar,
16-
.
17-
Export-Package: org.sofproject.gst.json
1813
Import-Package: org.eclipse.ui
14+
Export-Package: org.sofproject.gst.topo.ops

org.sofproject.gst.topo/src/org/sofproject/gst/topo/model/GstTopoNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public GstTopoConnection getOutgoingConnection() {
100100
public void serialize(Writer writer) throws IOException {
101101
writer.write(elem.getName());
102102
for (GstProperty prop : properties.values()) {
103-
//if (!prop.isChanged())
104-
// continue;
103+
if (!prop.isChanged())
104+
continue;
105105
writer.write(" ");
106106
prop.serialize(writer);
107107
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Copyright (c) 2019, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the Intel Corporation nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
*/
29+
30+
package org.sofproject.gst.topo.ops;
31+
32+
import java.io.BufferedReader;
33+
import java.io.FileReader;
34+
import java.io.IOException;
35+
import java.lang.reflect.InvocationTargetException;
36+
import java.nio.file.FileSystem;
37+
import java.nio.file.Path;
38+
import java.nio.file.Paths;
39+
40+
import org.eclipse.core.runtime.IProgressMonitor;
41+
import org.sofproject.core.AudioDevNodeProject;
42+
import org.sofproject.core.connection.AudioDevNodeConnection;
43+
import org.sofproject.core.ops.SimpleRemoteOp;
44+
import org.sofproject.topo.ui.json.JsonProperty;
45+
import org.sofproject.topo.ui.json.JsonUtils;
46+
47+
import com.jcraft.jsch.ChannelExec;
48+
import com.jcraft.jsch.JSchException;
49+
import com.jcraft.jsch.Session;
50+
51+
public class GstDockerOperation extends SimpleRemoteOp {
52+
53+
private JsonUtils jsonUtils;
54+
55+
public GstDockerOperation(AudioDevNodeConnection conn, JsonUtils jsonUtils) {
56+
super(conn);
57+
this.jsonUtils = jsonUtils;
58+
}
59+
60+
@Override
61+
public boolean isCancelable() {
62+
return true;
63+
}
64+
65+
@Override
66+
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
67+
monitor.beginTask("Sending json to docker", 100);
68+
69+
try {
70+
if (!conn.isConnected()) {
71+
throw new InvocationTargetException(new IllegalStateException("Node not connected"));
72+
}
73+
74+
JsonProperty jsonProperty = jsonUtils.getJsonProperty();
75+
76+
AudioDevNodeProject proj = conn.getProject();
77+
Session session = conn.getSession();
78+
ChannelExec channel = (ChannelExec) session.openChannel("exec");
79+
channel.setInputStream(null);
80+
81+
String jsonFileName = "pipeline.json";
82+
String projectPath = proj.getProject().getLocation().toString();
83+
Path partPathToJson = Paths.get(jsonProperty.getType().toLowerCase(), jsonProperty.getName(), jsonProperty.getVersion());
84+
Path fullPathToJson = Paths.get(projectPath, partPathToJson.toString(), jsonFileName);
85+
String linuxPartPathToJson = partPathToJson.toString();
86+
linuxPartPathToJson = linuxPartPathToJson.replace("\\", "/");
87+
88+
BufferedReader reader = new BufferedReader(new FileReader(fullPathToJson.toString()));
89+
String currentLine = reader.readLine();
90+
reader.close();
91+
92+
channel.setPty(true); // for ctrl+c sending
93+
String command = String.format(
94+
"docker exec -t video_analytics_serving_gstreamer /bin/bash -c \"cd pipelines; mkdir -p %s; cd %s; touch %s; echo \'%s\' > %s\"",
95+
linuxPartPathToJson, linuxPartPathToJson, jsonFileName, currentLine.replace("\"", "\\\""), jsonFileName);
96+
channel.setCommand(command);
97+
98+
channel.connect();
99+
100+
while (!channel.isEOF())
101+
;
102+
channel.disconnect();
103+
monitor.beginTask("Sending json to docker", 1000);
104+
105+
} catch (JSchException | IOException e) {
106+
throw new InvocationTargetException(e);
107+
}
108+
}
109+
110+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2019, Intel Corporation
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of the Intel Corporation nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
*/
29+
30+
package org.sofproject.gst.topo.ops;
31+
32+
import org.sofproject.core.connection.AudioDevNodeConnection;
33+
import org.sofproject.core.ops.IRemoteOp;
34+
import org.sofproject.core.ops.IRemoteOpsProvider;
35+
import org.sofproject.topo.ui.json.JsonUtils;
36+
37+
public class GstDockerOpsProvider implements IRemoteOpsProvider {
38+
39+
public static final String SEND_DOCKER = "org.sofproject.gst.topo.ops.senddocker";
40+
41+
public static final String[] OPS = { SEND_DOCKER };
42+
43+
JsonUtils jsonUtils;
44+
45+
public GstDockerOpsProvider(JsonUtils jsonUtils) {
46+
this.jsonUtils = jsonUtils;
47+
}
48+
49+
@Override
50+
public String[] getRemoteOpsIds() {
51+
return OPS;
52+
}
53+
54+
@Override
55+
public String getRemoteOpDisplayName(String opId) {
56+
switch (opId) {
57+
case SEND_DOCKER:
58+
return "Serialize Topology to Json & send to Docker";
59+
default:
60+
return null;
61+
}
62+
}
63+
64+
@Override
65+
public IRemoteOp createRemoteOp(String opId, AudioDevNodeConnection conn) {
66+
switch (opId) {
67+
case SEND_DOCKER:
68+
return new GstDockerOperation(conn, jsonUtils);
69+
default:
70+
return null;
71+
}
72+
}
73+
74+
}

org.sofproject.gst.topo/src/org/sofproject/gst/topo/ops/GstGraphOpsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public IRemoteOp createRemoteOp(String opId, AudioDevNodeConnection conn) {
6767
switch (opId) {
6868
case TEST_TOPO:
6969
if (conn == null) {
70-
conn = AudioDevNodeConnectionManager.getInstance().getConnection(graph.getFileInput().getProject());;
70+
conn = AudioDevNodeConnectionManager.getInstance().getConnection(graph.getFileInput().getProject());
7171
}
7272
return new GstTopoTestOperation(graph, conn);
7373
default:

org.sofproject.topo.ui/.classpath

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
</classpathentry>
88
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
99
<classpathentry kind="src" path="src"/>
10-
<classpathentry kind="lib" path="C:/Users/edominia/Downloads/javax-inject.jar"/>
10+
<classpathentry kind="lib" path="lib/javax-inject.jar"/>
11+
<classpathentry exported="true" kind="lib" path="lib/jackson-annotations-2.10.1.jar"/>
12+
<classpathentry exported="true" kind="lib" path="lib/jackson-core-2.10.1.jar"/>
13+
<classpathentry exported="true" kind="lib" path="lib/jackson-databind-2.10.1.jar"/>
1114
<classpathentry kind="output" path="bin"/>
1215
</classpath>

org.sofproject.topo.ui/META-INF/MANIFEST.MF

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@ Require-Bundle: org.eclipse.core.runtime;visibility:=reexport,
1616
org.eclipse.gef.zest.fx;bundle-version="5.0.1",
1717
org.eclipse.gef.zest.fx.ui;bundle-version="5.0.2",
1818
org.sofproject.core,
19-
org.sofproject.ui
19+
org.sofproject.ui,
20+
org.sofproject.gst.topo
2021
Import-Package: com.google.common.collect;version="21.0.0",
2122
com.google.common.reflect;version="21.0.0",
2223
com.google.inject;version="1.3.0",
2324
com.google.inject.binder;version="1.3.0",
2425
com.google.inject.multibindings;version="1.3.0",
25-
com.google.inject.util;version="1.3.0",
26-
org.sofproject.gst.json
26+
com.google.inject.util;version="1.3.0"
2727
Bundle-Vendor: Intel Corporation
2828
Export-Package: org.sofproject.topo.ui.editor,
29-
org.sofproject.topo.ui.graph
29+
org.sofproject.topo.ui.graph,
30+
org.sofproject.topo.ui.json
31+
Bundle-ClassPath: lib/jackson-annotations-2.10.1.jar,
32+
lib/jackson-core-2.10.1.jar,
33+
lib/jackson-databind-2.10.1.jar,
34+
.

org.sofproject.topo.ui/build.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ output.. = bin/
33
bin.includes = META-INF/,\
44
.,\
55
plugin.xml,\
6-
bin/
6+
bin/,\
7+
lib/jackson-annotations-2.10.1.jar,\
8+
lib/jackson-core-2.10.1.jar,\
9+
lib/jackson-databind-2.10.1.jar

0 commit comments

Comments
 (0)