Skip to content

Commit 64cd84a

Browse files
author
abhishek
committed
added some logging
1 parent 3372064 commit 64cd84a

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

get-object/src/main/java/io/fnproject/example/ObjectStoreGetFunction.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public class ObjectStoreGetFunction {
2121
private ObjectStorage objStoreClient = null;
2222

2323
public ObjectStoreGetFunction() {
24-
System.err.println("Inside ObjectStoreGetFunction ctor()");
24+
System.err.println("Inside ObjectStoreGetFunction constructor");
2525

2626
try {
27-
String privateKey = System.getenv().getOrDefault("OCI_PRIVATE_KEY_FILE_NAME", "oci_api_key.pem");
27+
String privateKey = System.getenv().get("OCI_PRIVATE_KEY_FILE_NAME");
2828
System.err.println("Private key " + privateKey);
2929
Supplier<InputStream> privateKeySupplier = () -> {
3030
InputStream is = null;
@@ -48,14 +48,11 @@ public ObjectStoreGetFunction() {
4848
.privateKeySupplier(privateKeySupplier)
4949
.build();
5050

51-
System.err.println("AuthenticationDetailsProvider setup..");
52-
5351
objStoreClient = new ObjectStorageClient(provider);
5452
objStoreClient.setRegion(System.getenv().get("REGION"));
5553

56-
System.err.println("ObjectStorage client setup");
5754
} catch (Throwable ex) {
58-
System.err.println("Error occurred in ObjectStoreListFunction ctor " + ex.getMessage());
55+
System.err.println("Error occurred in ObjectStoreListFunction constructor " + ex.getMessage());
5956

6057
}
6158
}
@@ -92,7 +89,7 @@ public String handle(GetObjectInfo objectInfo) {
9289
}
9390
try {
9491

95-
String nameSpace = System.getenv().getOrDefault("NAMESPACE", "test-namespace");
92+
String nameSpace = System.getenv().get("NAMESPACE");
9693

9794
GetObjectRequest gor = GetObjectRequest.builder()
9895
.namespaceName(nameSpace)
@@ -104,6 +101,8 @@ public String handle(GetObjectInfo objectInfo) {
104101
result = new BufferedReader(new InputStreamReader(response.getInputStream()))
105102
.lines().collect(Collectors.joining("\n"));
106103

104+
System.err.println("Finished reading content for object " + objectInfo.getName());
105+
107106
} catch (Exception e) {
108107
System.err.println("Error fetching object " + e.getMessage());
109108
result = "Error fetching object " + e.getMessage();

list-objects/src/main/java/io/fnproject/example/ObjectStoreListFunction.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public class ObjectStoreListFunction {
2121
private ObjectStorage objStoreClient = null;
2222

2323
public ObjectStoreListFunction() {
24-
System.err.println("Inside ObjectStoreListFunction ctor");
24+
System.err.println("Inside ObjectStoreListFunction constructor");
2525
try {
26-
String privateKey = System.getenv().getOrDefault("OCI_PRIVATE_KEY_FILE_NAME", "oci_api_key.pem");
26+
String privateKey = System.getenv().get("OCI_PRIVATE_KEY_FILE_NAME");
2727
System.err.println("Private key " + privateKey);
2828

2929
Supplier<InputStream> privateKeySupplier = () -> {
@@ -48,14 +48,11 @@ public ObjectStoreListFunction() {
4848
.privateKeySupplier(privateKeySupplier)
4949
.build();
5050

51-
System.err.println("AuthenticationDetailsProvider setup");
52-
5351
objStoreClient = new ObjectStorageClient(provider);
5452
objStoreClient.setRegion(System.getenv().get("REGION"));
5553

56-
System.err.println("ObjectStorage client setup");
5754
} catch (Exception ex) {
58-
System.err.println("Error occurred in ObjectStoreListFunction ctor " + ex.getMessage());
55+
System.err.println("Error occurred in ObjectStoreListFunction constructor " + ex.getMessage());
5956
}
6057
}
6158

@@ -67,7 +64,7 @@ public List<String> handle(String bucketName) {
6764

6865
List<String> objNames = null;
6966
try {
70-
String nameSpace = System.getenv().getOrDefault("NAMESPACE", "test-namespace");
67+
String nameSpace = System.getenv().get("NAMESPACE");
7168

7269
ListObjectsRequest lor = ListObjectsRequest.builder()
7370
.namespaceName(nameSpace)
@@ -80,6 +77,8 @@ public List<String> handle(String bucketName) {
8077
.map((objSummary) -> objSummary.getName())
8178
.collect(Collectors.toList());
8279

80+
System.err.println("Got list of objects in bucket " + bucketName);
81+
8382
} catch (Exception e) {
8483
System.err.println("Error invoking object store API " + e.getMessage());
8584
}

put-object/src/main/java/io/fnproject/example/ObjectStorePutFunction.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public class ObjectStorePutFunction {
2020
private ObjectStorage objStoreClient = null;
2121

2222
public ObjectStorePutFunction() {
23-
System.err.println("Inside ObjectStorePutFunction ctor");
23+
System.err.println("Inside ObjectStorePutFunction constructor");
2424
try {
25-
String privateKey = System.getenv().getOrDefault("OCI_PRIVATE_KEY_FILE_NAME", "oci_api_key.pem");
25+
String privateKey = System.getenv().get("OCI_PRIVATE_KEY_FILE_NAME");
2626
System.err.println("Private key " + privateKey);
2727
Supplier<InputStream> privateKeySupplier = () -> {
2828
InputStream is = null;
@@ -46,14 +46,11 @@ public ObjectStorePutFunction() {
4646
.privateKeySupplier(privateKeySupplier)
4747
.build();
4848

49-
System.err.println("AuthenticationDetailsProvider setup");
50-
5149
objStoreClient = new ObjectStorageClient(provider);
5250
objStoreClient.setRegion(System.getenv().get("REGION"));
5351

54-
System.err.println("ObjectStorage client setup");
5552
} catch (Exception ex) {
56-
System.err.println("Error occurred in ObjectStorePutFunction ctor " + ex.getMessage());
53+
System.err.println("Error occurred in ObjectStorePutFunction constructor " + ex.getMessage());
5754
}
5855
}
5956

@@ -92,7 +89,6 @@ public void setContent(String content) {
9289

9390
}
9491

95-
9692
public String handle(ObjectInfo objectInfo) {
9793
System.err.println("Inside ObjectStorePutFunction/handle");
9894
String result = "FAILED";
@@ -102,7 +98,7 @@ public String handle(ObjectInfo objectInfo) {
10298
}
10399
try {
104100

105-
String nameSpace = System.getenv().getOrDefault("NAMESPACE", "test-namespace");
101+
String nameSpace = System.getenv().get("NAMESPACE");
106102

107103
PutObjectRequest por = PutObjectRequest.builder()
108104
.namespaceName(nameSpace)
@@ -112,7 +108,8 @@ public String handle(ObjectInfo objectInfo) {
112108
.build();
113109

114110
PutObjectResponse poResp = objStoreClient.putObject(por);
115-
result = "OPC ID for upload operation for object " + objectInfo.name + " - " + poResp.getOpcRequestId();
111+
result = "Successfully submitted Put request for object " + objectInfo.name + "in bucket " +objectInfo.bucketName + ". OPC reuquest ID is " + poResp.getOpcRequestId();
112+
System.err.println(result);
116113

117114
} catch (Exception e) {
118115
System.err.println("Error invoking object store API " + e.getMessage());

0 commit comments

Comments
 (0)