This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AuthenticationDetailsProvider provider = SimpleAuthenticationDetailsProvider | |
.builder() | |
.tenantId(System.getenv().get("TENANCY")) | |
.userId(System.getenv().get("USER")) | |
.fingerprint(System.getenv().get("FINGERPRINT")) | |
.passPhrase(System.getenv().get("PASSPHRASE")) | |
.privateKeySupplier(privateKeySupplier) | |
.build(); | |
objStoreClient = new ObjectStorageClient(provider); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String privateKey = System.getenv().get("OCI_PRIVATE_KEY_FILE_NAME"); | |
Supplier<InputStream> privateKeySupplier = () -> { | |
InputStream is = null; | |
String ociPrivateKeyPath = "/function/" + privateKey; | |
System.err.println("Private key location - " + ociPrivateKeyPath); | |
try { | |
is = new FileInputStream(ociPrivateKeyPath); | |
} catch (FileNotFoundException ex) { | |
System.err.println("Problem accessing OCI private key at " + ociPrivateKeyPath + " - " + ex.getMessage()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void bootstrap() throws IOException { | |
String hostname = "0.0.0.0"; | |
String port = "9090"; | |
URI baseUri = UriBuilder.fromUri("http://" + hostname + "/").port(Integer.parseInt(port)).build(); | |
ResourceConfig config = new ResourceConfig(ServiceManagerResource.class); | |
HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("tweets/producer") | |
public class ServiceManagerResource { | |
@GET | |
public Response start() { | |
Response r = null; | |
try { | |
ServiceLifecycleManager.getInstance().start(); | |
r = Response.ok("Tweets Producer started. Tracking - "+ ServiceLifecycleManager.TRACKED_TERMS) | |
.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onStatus(Status status) { | |
List<String> matchedTerms = new ArrayList<>(getMatchedTerms(status.getText())); | |
if (!status.isPossiblySensitive() && !matchedTerms.isEmpty()) { | |
String tweetID = String.valueOf(status.getId()); | |
String tweetText = status.getText(); | |
System.out.println("Matched terms - " + matchedTerms); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: kafka-producer-deployment | |
spec: | |
selector: | |
matchLabels: | |
app: kafka-producer | |
replicas: 1 # 1 instance only | |
template: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: kafka-streams-app-deployment | |
spec: | |
selector: | |
matchLabels: | |
app: kafka-streams-app | |
replicas: 2 | |
template: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: kafka-streams-app-service | |
labels: | |
app: kafka-streams-app | |
spec: | |
type: NodePort | |
ports: | |
- port: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* POJO representing list of Metric(s) | |
*/ | |
@XmlRootElement | |
@XmlAccessorType(XmlAccessType.FIELD) | |
public class Metrics { | |
private final List<Metric> metrics; | |
public Metrics() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* POJO representing a single CPU metric | |
*/ | |
@XmlRootElement | |
@XmlAccessorType(XmlAccessType.FIELD) | |
public class Metric { | |
private String machine; | |
private String cpu; | |
private String source; |