Commit f918042c authored by Ryan Berkheimer's avatar Ryan Berkheimer
Browse files

adding new makefile stubs for demo resources.

parent 546cd603
Pipeline #5996 failed with stage
in 0 seconds
......@@ -42,9 +42,9 @@ TEST_RESOURCE_DIR=$(PROJECT_ROOT)/libs
run-native-tests: export LD_LIBRARY_PATH = $(JAVA_HOME)/lib/jli:$(JAVA_HOME)/lib/server
run-native-tests: export CLASSPATH = $(TEST_RESOURCE_DIR)/test/java/jars/$(SRC_JAR)
.PHONY: build-c_cpp prep-java build-java dist-java run-native-tests copy-docs #cleanup
.PHONY: build-c_cpp prep-java build-java dist-java run-native-tests copy-docs create-demo-resources cleanup
all: build-c_cpp prep-java build-java dist-java copy-docs run-native-tests #cleanup
all: build-c_cpp prep-java build-java dist-java copy-docs run-native-tests create-demo-resources cleanup
build-c_cpp:
@echo "Building the shared library for C/C++ native sessions and the distributable native C artifacts."
......@@ -66,7 +66,7 @@ cleanup:
prep-java:
@echo "Cleaning any residual Java artifacts."
@rm -rf $(JAVA_ARTIFACT_DIR)
@rm -rf $(API_DOCS_DIR)
@rm -rf $(API_DOCS_DIR)P
@echo "Java ready for build."
build-java:
......@@ -92,6 +92,10 @@ copy-docs:
@-cd $(DOCS_SRC_DIR) && tar -cf $(API_DOCS_DIR)/messageapi_docs.tar *
@echo "Finished copying API docs for distribution."
create-demo-resources:
@echo "Creating Demo resources."
@echo "Finished creating Demo resources."
run-native-tests:
@echo "Running native C/C++ session test."
@-cd $(TEST_RESOURCE_DIR)/test/c/session && ./SessionDemo.bin
......@@ -111,4 +115,12 @@ install:
@chmod +x install.sh
@./install.sh "C_CPP"
@rm install.sh
@echo "Finished installing package, validate ~/.bashrc and env vars for success."
\ No newline at end of file
@echo "Finished installing package, validate ~/.bashrc and env vars for success."
demo: install
@echo "Installing demo dependencies."
@echo "Finished insatlling demo dependencies."
demo-k3: install-k3
@echo "Installing demo dependencies."
@echo "Finished insatlling demo dependencies."
\ No newline at end of file
%% Cell type:markdown id: tags:
# Ensure Basic Kernel Operation
%% Cell type:code id: tags:
``` c
#include <stdio.h>
int main() {
printf("Hello world\n");
}
```
%%%% Output: stream
Hello world
%% Cell type:markdown id: tags:
# Very Verbose File Reader
%% Cell type:code id: tags:
``` c
//%cflags:-fPIC -std=c99 -I/home/messageapi/.messageapi/c/headers -I/usr/lib/jvm/java-11-openjdk-11.0.8.10-1.el7.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.8.10-1.el7.x86_64/include/linux -L/workspaces/messageapi/libs/test/c/session/so -lmessageapi
#include <jni.h>
#include <stdio.h>
#include "messageapi_structs.h"
#include "MessageApiSessionLib.h"
int main()
{
puts("In our native session demo test!\n");
puts("Hello, World\n");
fflush(stdout);
//puts("In our native session demo test!\n");
//puts("Hello, World\n");
//fflush(stdout);
session *session = createSession("/workspaces/messageapi/resources/test/file-reader-native/manifest.json");
puts("Successfully created session.");
fflush(stdout);
//puts("Successfully created session.");
//fflush(stdout);
request *request1 = createRequest(session);
puts("Successfully created a request.");
fflush(stdout);
//puts("Successfully created a request.");
//fflush(stdout);
record *record1 = createRequestRecord(session, request1);
puts("Successfully created a request record.");
fflush(stdout);
//puts("Successfully created a request record.");
//fflush(stdout);
field *field1 = getField(session, record1, "file-path");
puts("Successfully retrieved the file-path field from the request record.");
fflush(stdout);
//puts("Successfully retrieved the file-path field from the request record.");
//fflush(stdout);
setFieldStringVal(session, field1, "/workspaces/messageapi/resources/test/inputs/file-reader/simpletextfile");
puts(getFieldStringVal(session, field1));
fflush(stdout);
//puts(getFieldStringVal(session, field1));
//fflush(stdout);
puts("Successfully set the field string value for the file-path field from the request record.");
fflush(stdout);
//puts("Successfully set the field string value for the file-path field from the request record.");
//fflush(stdout);
//record_list *session_records = createRecordList(session);
//addRecord(session, session_records, record1);
//setRequestRecords(session, request1, session_records);
//record *record2 = createRequestRecord(session, request1);
//field *field2 = getField(session, record2, "file-path");
//setFieldStringVal(session, field2, "/workspaces/messageapi/resources/test/inputs/file-reader/proc_sm_gtsnp_data_ftp_CF6_cf6_20190506.txt");
record_list *request_records = getRequestRecords(session, request1);
printf("Request record count: %d\n", request_records->count);
fflush(stdout);
//record_list *request_records = getRequestRecords(session, request1);
//printf("Request record count: %d\n", request_records->count);
//fflush(stdout);
response *response = submitRequest(session, request1);
puts("Response completion status right after submission:");
fputs(isComplete(session, response) ? "true" : "false", stdout);
puts("");
fflush(stdout);
//puts("Response completion status right after submission:");
//fputs(isComplete(session, response) ? "true" : "false", stdout);
//puts("");
//fflush(stdout);
puts("Successfully submitted the request.");
fflush(stdout);
//puts("Successfully submitted the request.");
//fflush(stdout);
puts(getFieldStringVal(session, field1));
fflush(stdout);
//puts(getFieldStringVal(session, field1));
//fflush(stdout);
while (!isComplete(session, response)) {}
puts("Successfully returned from the request.");
fflush(stdout);
//puts("Successfully returned from the request.");
//fflush(stdout);
//puts(getFieldStringVal(session, field1));
//fflush(stdout);
record_list *response_records = getResponseRecords(session, response);
rejection_list *response_rejections = getResponseRejections(session, response);
printf("Record count: %d\n", response_records->count);
printf("Rejection count: %d\n", response_rejections->count);
printf("Record field count: %d\n", )
//rejection_list *response_rejections = getResponseRejections(session, response);
//printf("Record count: %d\n", response_records->count);
//printf("Rejection count: %d\n", response_rejections->count);
for (int j=0; j<response_records->count; j++) {
record *return_record = getRecord(session, response_records, j);
string_list *fieldIds = getFieldIds(session, return_record);
for (int i=0; i<fieldIds->count; i++) {
field *returnField = getField(session, return_record, fieldIds->strings[i]);
//printf("FieldType: %s\n", getFieldType(session,returnField));
//if (strcmp(getFieldType(session,returnField), "integer") == 0) {
// printf("Field id: %s, Field type: %d\n", fieldIds->strings[i], getFieldIntVal(session,returnField));
//} else
if (strcmp(getFieldType(session,returnField), "string") == 0) {
//printf("Field id: %s, Field value: %s\n", fieldIds->strings[i], getFieldStringVal(session,returnField));
printf("%s\n", getFieldStringVal(session,returnField));
}
}
}
fflush(stdout);
releaseSession(session);
}
```
%%%% Output: stream
Hi
There
User
I
Am
A
Test!
%% Cell type:markdown id: tags:
# File Reader, slimmed
%% Cell type:code id: tags:
``` c
//%cflags:-std=c99 -I/home/messageapi/.messageapi/c/headers -I/usr/lib/jvm/java-11-openjdk-11.0.8.10-1.el7.x86_64/include -I/usr/lib/jvm/java-11-openjdk-11.0.8.10-1.el7.x86_64/include/linux -L/workspaces/messageapi/libs/test/c/session/so -lmessageapi
#include <jni.h>
#include <stdio.h>
#include "messageapi_structs.h"
#include "MessageApiSessionLib.h"
int main() {
const char *manifest = "/workspaces/messageapi/resources/test/file-reader-native/manifest.json";
const char *textfile = "/workspaces/messageapi/resources/test/inputs/file-reader/simpletextfile";
session *session = createSession(manifest);
request *request = createRequest(session);
record *input_record = createRequestRecord(session, request);
setFieldStringVal(session, getField(session, input_record, "file-path"), textfile);
response *response = submitRequest(session, request);
while (!isComplete(session, response)) {}
record_list *response_records = getResponseRecords(session, response);
for (int j=0; j<response_records->count; j++) {
record *return_record = getRecord(session, response_records, j);
string_list *fieldIds = getFieldIds(session, return_record);
for (int i=0; i<fieldIds->count; i++) {
field *returnField = getField(session, return_record, fieldIds->strings[i]);
if (strcmp(getFieldType(session,returnField), "string") == 0) {
printf("%s\n", getFieldStringVal(session,returnField));
}
}
}
fflush(stdout);
releaseSession(session);
}
```
%%%% Output: stream
In our native session demo test!
Hello, World
Successfully created session.
Successfully created a request.
Successfully created a request record.
Successfully retrieved the file-path field from the request record.
/workspaces/messageapi/resources/test/inputs/file-reader/simpletextfile
Successfully set the field string value for the file-path field from the request record.
Request record count: 1
Response completion status right after submission:
false
Successfully submitted the request.
/workspaces/messageapi/resources/test/inputs/file-reader/simpletextfile
Successfully returned from the request.
Record count: 7
Rejection count: 0
Hi
There
User
I
Am
A
Test!
%% Cell type:code id: tags:
``` c
```
......
%% Cell type:code id: tags:
``` java
List<String> added = %jars /workspaces/messageapi/build/libs/messageapi-core-1.0.0.jar
```
%% Cell type:code id: tags:
``` java
import gov.noaa.messageapi.interfaces.ISession;
```
%% Cell type:code id: tags:
``` java
import gov.noaa.messageapi.sessions.StandardSession;
```
%% Cell type:code id: tags:
``` java
ISession session = new StandardSession("/workspaces/messageapi/resources/test/native-condition/parameters.json");
```
%% Cell type:code id: tags:
``` java
import gov.noaa.messageapi.interfaces.*;
```
%% Cell type:code id: tags:
``` java
IRequest request = session.createRequest()
```
%% Cell type:code id: tags:
``` java
IRecord record = request.createRecord();
IRecord record2 = request.createRecord();
```
%% Cell type:code id: tags:
``` java
record.setField("int-field", 1);
record2.setField("int-field", 100);
```
%% Cell type:code id: tags:
``` java
record.getField("int-field").getValue()
```
%%%% Output: execute_result
1
%% Cell type:code id: tags:
``` java
IResponse response = request.submit()
```
%% Cell type:code id: tags:
``` java
response.isComplete()
```
%%%% Output: execute_result
true
%% Cell type:code id: tags:
``` java
response.getRecords().size()
```
%%%% Output: execute_result
3
%% Cell type:code id: tags:
``` java
response.getRecords().forEach(r -> r.getFields().forEach(f->System.out.println(f.getId() + ", " + f.getValue())))
```
%%%% Output: stream
int-field, 100
int-field, 1
int-field, 100
int-field, 1
%% Cell type:code id: tags:
``` java
IResponse response2 = request.submit()
```
%% Cell type:code id: tags:
``` java
response2.isComplete()
```
%%%% Output: execute_result
true
%% Cell type:code id: tags:
``` java
response2.getRecords().size()
```
%%%% Output: execute_result
3
%% Cell type:code id: tags:
``` java
record.getField("int-field").getValue()
```
%%%% Output: execute_result
1
%% Cell type:code id: tags:
``` java
record.getFields()
```
%%%% Output: execute_result
[gov.noaa.messageapi.fields.DefaultField@18fc3f5f]
[gov.noaa.messageapi.fields.DefaultField@233d0729]
%% Cell type:code id: tags:
``` java
record.getFields().forEach(f->System.out.println(f.getId() + ", " + f.getValue()))
```
%%%% Output: stream
int-field, 1
%% Cell type:code id: tags:
``` java
response.getRecords().size()
```
%%%% Output: execute_result
3
%% Cell type:code id: tags:
``` java
response.getRejections().size()
```
%%%% Output: execute_result
0
%% Cell type:code id: tags:
``` java
response2.getRejections().size()
```
%%%% Output: execute_result
0
%% Cell type:code id: tags:
``` java
ISession fileReaderSession = new StandardSession("/workspaces/messageapi/resources/test/file-reader/parameter_map_style.json")
```
%% Cell type:code id: tags:
``` java
IRequest fileReaderRequest = fileReaderSession.createRequest();
```
%% Cell type:code id: tags:
``` java
IRecord record = fileReaderRequest.createRecord();
```
%% Cell type:code id: tags:
``` java
record.getFields().forEach(f->System.out.println(f.getId() + ", " + f.getValue()))
```
%%%% Output: stream
file-path, null
%% Cell type:code id: tags:
``` java
record.setField("file-path", "/workspaces/messageapi/build/resources/test/inputs/file-reader/proc_sm_gtsnp_data_ftp_CF6_cf6_20190506.txt");
```
%% Cell type:code id: tags:
``` java
IResponse fileReaderResponse = fileReaderRequest.submit();
fileReaderResponse.isComplete();
```
%%%% Output: execute_result
false
%% Cell type:code id: tags:
``` java
fileReaderResponse.isComplete();
```
%%%% Output: execute_result
false
%% Cell type:code id: tags:
``` java
fileReaderResponse.getRecords().size();
```
%%%% Output: execute_result
79794
%% Cell type:code id: tags:
``` java
fileReaderResponse.getRecords().get(100);
```
%%%% Output: execute_result
gov.noaa.messageapi.records.schema.SchemaRecord@3881fdaf
gov.noaa.messageapi.records.schema.SchemaRecord@3136b65f
%% Cell type:code id: tags:
``` java
fileReaderResponse.getRecords().get(100).getFields().forEach(f -> System.out.println(f.getId() + ", " + f.getValue()))
```
%%%% Output: stream
value, # LAST OF SEVERAL OCCURRENCES
length, 29
number, 100
%% Cell type:code id: tags:
``` java
fileReaderResponse.getRecords().get(99).getField("value").getValue()
```
%%%% Output: execute_result
NOTES:
%% Cell type:code id: tags:
``` java
import java.util.List;
```
%% Cell type:markdown id: tags:
**FTP Lister Using a Standard Session**
%% Cell type:code id: tags:
``` java
import gov.noaa.messageapi.sessions.StandardSession;
import gov.noaa.messageapi.interfaces.*;
```
%% Cell type:code id: tags:
``` java
String parameterMap = "/workspaces/messageapi/resources/test/ftp-lister/parameters_map_style.json";
ISession ftpListSession = new StandardSession(parameterMap);
IRequest ftpListRequest = ftpListSession.createRequest();
IRecord ftpListRecord = ftpListRequest.createRecord();
ftpListRecord.setField("directory", "pub/download/hidden");
IResponse ftpListResponse = ftpListRequest.submit();
while (!ftpListResponse.isComplete()) {}
System.out.println("Return record count: " + ftpListResponse.getRecords().size());
ftpListResponse.getRecords().forEach(ftpRecord -> {
System.out.println(ftpRecord.getField("name").getValue());
System.out.println(ftpRecord.getField("server").getValue());
System.out.println(ftpRecord.getField("path").getValue());
System.out.println(ftpRecord.getField("size").getValue());
System.out.println(ftpRecord.getField("type").getValue());
System.out.println(ftpRecord.getField("modified").getValue());
});
ftpListResponse.getRejections().forEach(ftpRejection -> {
System.out.println("Rejection!");
});
```
%%%% Output: stream
Return record count: 0
%% Cell type:code id: tags:
``` java
```
%% Cell type:code id: tags:
``` java
```
......