index int64 | repo_id string | file_path string | content string |
|---|---|---|---|
0 | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai/superstream/Superstream.java | package ai.superstream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.function.Consumer;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.Properties;
import java.util.Set;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.PartitionInfo;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.common.serialization.StringDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.protobuf.DescriptorProtos.FileDescriptorSet;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.DynamicMessage;
import com.google.protobuf.util.JsonFormat;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.google.protobuf.DescriptorProtos;
import io.nats.client.Connection;
import io.nats.client.Nats;
import io.nats.client.Options;
import io.nats.client.Subscription;
import io.nats.client.api.ServerInfo;
import io.nats.client.ConnectionListener;
import io.nats.client.Dispatcher;
import io.nats.client.JetStream;
import io.nats.client.Message;
import io.nats.client.MessageHandler;
public class Superstream {
public Connection brokerConnection;
public JetStream jetstream;
public String superstreamJwt;
public String superstreamNkey;
public byte[] descriptorAsBytes;
public Descriptors.Descriptor descriptor;
public String natsConnectionID;
public String clientHash;
public String accountName;
public int learningFactor = 20;
public int learningFactorCounter = 0;
public boolean learningRequestSent = false;
private static final ObjectMapper objectMapper = new ObjectMapper();
public String ProducerSchemaID = "0";
public String ConsumerSchemaID = "0";
public Map<String, Descriptors.Descriptor> SchemaIDMap = new HashMap<>();
public Map<String, Object> configs;
public final SuperstreamCounters clientCounters = new SuperstreamCounters();
private Subscription updatesSubscription;
private String host;
private String token;
public String type;
public Boolean reductionEnabled;
public Map<String, Set<Integer>> topicPartitions = new ConcurrentHashMap<>();
public ExecutorService executorService = Executors.newFixedThreadPool(3);
private Integer kafkaConnectionID = 0;
public Boolean superstreamReady = false;
private String tags = "";
public Boolean canStart = false;
private CompressionUpdateCallback compressionUpdateCallback;
public Boolean compressionEnabled;
private final ConcurrentHashMap<String, AtomicReference<SuperstreamCounters>> clientCountersMap = new ConcurrentHashMap<>();
public Superstream(String token, String host, Integer learningFactor, Map<String, Object> configs,
Boolean enableReduction, String type, String tags) {
this.learningFactor = learningFactor;
this.token = token;
this.host = host;
this.configs = configs;
this.reductionEnabled = enableReduction;
this.type = type;
this.tags = tags;
this.compressionEnabled = getBooleanEnv("SUPERSTREAM_COMPRESSION_ENABLED", false);
}
public Superstream(String token, String host, Integer learningFactor, Map<String, Object> configs,
Boolean enableReduction, String type) {
this(token, host, learningFactor, configs, enableReduction, type, "");
}
public void init() {
executorService.submit(() -> {
try {
initializeNatsConnection(token, host);
if (this.brokerConnection != null) {
registerClient(configs);
waitForStart();
if (!canStart) {
throw new Exception("Could not start superstream");
}
subscribeToUpdates();
superstreamReady = true;
reportClientsUpdate();
sendClientTypeUpdateReq();
}
} catch (Exception e) {
handleError(e.getMessage());
}
});
}
public void close() {
try {
if (brokerConnection != null) {
brokerConnection.close();
}
executorService.shutdown();
} catch (Exception e) {
}
}
public void setCompressionUpdateCallback(CompressionUpdateCallback callback) {
this.compressionUpdateCallback = callback;
}
public void updateClientCounters(Consumer<SuperstreamCounters> updateFunction) {
clientCountersMap.compute(clientHash, (key, counterRef) -> {
if (counterRef == null) {
counterRef = new AtomicReference<>(new SuperstreamCounters());
}
counterRef.updateAndGet(counters -> {
updateFunction.accept(counters);
return counters;
});
return counterRef;
});
}
private Boolean getBooleanEnv(String key, Boolean defaultValue) {
String value = System.getenv(key);
return (value != null) ? Boolean.parseBoolean(value) : defaultValue;
}
public interface CompressionUpdateCallback {
void onCompressionUpdate(boolean enabled, String type);
}
private void initializeNatsConnection(String token, String host) {
try {
Options options = new Options.Builder()
.server(host)
.userInfo(Consts.superstreamInternalUsername, token)
.maxReconnects(-1)
.connectionTimeout(Duration.ofSeconds(10))
.reconnectWait(Duration.ofSeconds(1))
.connectionListener(new ConnectionListener() {
@Override
public void connectionEvent(Connection conn, Events type) {
if (type == Events.DISCONNECTED) {
brokerConnection = null;
superstreamReady = false;
System.out.println("superstream: Disconnected");
} else if (type == Events.RECONNECTED) {
try {
brokerConnection = conn;
if (brokerConnection != null) {
natsConnectionID = generateNatsConnectionID();
Map<String, Object> reqData = new HashMap<>();
reqData.put("new_nats_connection_id", natsConnectionID);
reqData.put("client_hash", clientHash);
ObjectMapper mapper = new ObjectMapper();
byte[] reqBytes = mapper.writeValueAsBytes(reqData);
brokerConnection.publish(Consts.clientReconnectionUpdateSubject, reqBytes);
subscribeToUpdates();
superstreamReady = true;
reportClientsUpdate();
}
} catch (Exception e) {
System.out.println(
"superstream: Failed to reconnect: " + e.getMessage());
}
System.out.println("superstream: Reconnected to superstream");
}
}
})
.build();
Connection nc = Nats.connect(options);
if (nc == null) {
throw new Exception(String.format("Failed to connect to host: %s", host));
}
JetStream js = nc.jetStream();
if (js == null) {
throw new Exception(String.format("Failed to connect to host: %s", host));
}
brokerConnection = nc;
jetstream = js;
natsConnectionID = generateNatsConnectionID();
} catch (Exception e) {
System.out.println(String.format("superstream: %s", e.getMessage()));
}
}
private String generateNatsConnectionID() {
ServerInfo serverInfo = brokerConnection.getServerInfo();
String connectedServerName = serverInfo.getServerName();
int serverClientID = serverInfo.getClientId();
return connectedServerName + ":" + serverClientID;
}
public void registerClient(Map<String, ?> configs) {
try {
String kafkaConnID = consumeConnectionID();
if (kafkaConnID != null) {
try {
kafkaConnectionID = Integer.parseInt(kafkaConnID);
} catch (Exception e) {
kafkaConnectionID = 0;
}
}
Map<String, Object> reqData = new HashMap<>();
reqData.put("nats_connection_id", natsConnectionID);
reqData.put("language", "java");
reqData.put("learning_factor", learningFactor);
reqData.put("version", Consts.sdkVersion);
reqData.put("config", normalizeClientConfig(configs));
reqData.put("reduction_enabled", reductionEnabled);
reqData.put("connection_id", kafkaConnectionID);
reqData.put("tags", tags);
ObjectMapper mapper = new ObjectMapper();
byte[] reqBytes = mapper.writeValueAsBytes(reqData);
Message reply = brokerConnection.request(Consts.clientRegisterSubject, reqBytes, Duration.ofMinutes(5));
if (reply != null) {
@SuppressWarnings("unchecked")
Map<String, Object> replyData = mapper.readValue(reply.getData(), Map.class);
Object clientHashObject = replyData.get("client_hash");
if (clientHashObject != null) {
clientHash = clientHashObject.toString();
} else {
System.out.println("superstream: client_hash is not a valid string: " + clientHashObject);
}
Object accountNameObject = replyData.get("account_name");
if (accountNameObject != null) {
accountName = accountNameObject.toString();
} else {
System.out.println("superstream: account_name is not a valid string: " + accountNameObject);
}
Object learningFactorObject = replyData.get("learning_factor");
if (learningFactorObject instanceof Integer) {
learningFactor = (Integer) learningFactorObject;
} else if (learningFactorObject instanceof String) {
try {
learningFactor = Integer.parseInt((String) learningFactorObject);
} catch (NumberFormatException e) {
System.out.println(
"superstream: learning_factor is not a valid integer: " + learningFactorObject);
}
} else {
System.out.println("superstream: learning_factor is not a valid integer: " + learningFactorObject);
}
} else {
String errMsg = "superstream: registering client: No reply received within the timeout period.";
System.out.println(errMsg);
handleError(errMsg);
}
} catch (Exception e) {
System.out.println(String.format("superstream: %s", e.getMessage()));
}
}
private void waitForStart() {
CountDownLatch latch = new CountDownLatch(1);
Dispatcher dispatcher = brokerConnection.createDispatcher((msg) -> {
try {
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> messageData = mapper.readValue(msg.getData(), Map.class);
if (messageData.containsKey("start")) {
boolean start = (Boolean) messageData.get("start");
if (start) {
canStart = true;
latch.countDown(); // continue and stop the wait
} else {
String err = (String) messageData.get("error");
System.out.println("superstream: Could not start superstream: " + err);
Thread.currentThread().interrupt();
}
}
} catch (Exception e) {
e.printStackTrace();
}
});
dispatcher.subscribe(String.format(Consts.clientStartSubject, clientHash)); // replace with your specific subject
try {
if (!latch.await(10, TimeUnit.MINUTES)) {
System.out.println("superstream: Could not connect to superstream for 10 minutes.");
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
System.out.println("superstream: Could not start superstream: " + e.getMessage());
} finally {
dispatcher.unsubscribe(String.format(Consts.clientStartSubject, clientHash));
}
}
private String consumeConnectionID() {
Properties consumerProps = copyAuthConfig();
consumerProps.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
consumerProps.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
consumerProps.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");
consumerProps.put(Consts.superstreamInnerConsumerKey, "true");
consumerProps.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, 1);
String connectionId = null;
KafkaConsumer<String, String> consumer = null;
try {
consumer = new KafkaConsumer<>(consumerProps);
List<PartitionInfo> partitions = consumer.partitionsFor(Consts.superstreamMetadataTopic, Duration.ofMillis(10000));
if (partitions == null || partitions.isEmpty()) {
if (consumer != null) {
consumer.close();
}
return "0";
}
TopicPartition topicPartition = new TopicPartition(Consts.superstreamMetadataTopic, 0);
consumer.assign(Collections.singletonList(topicPartition));
consumer.seekToEnd(Collections.singletonList(topicPartition));
long endOffset = consumer.position(topicPartition);
if (endOffset > 0) {
consumer.seek(topicPartition, endOffset - 1);
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(10000));
if (!records.isEmpty()) {
connectionId = records.iterator().next().value();
}
}
} catch (Exception e) {
if (e.getMessage().toLowerCase().contains("timeout")) {
try {
Thread.sleep(10000);
if (consumer == null) {
consumer = new KafkaConsumer<>(consumerProps);
}
List<PartitionInfo> partitions = consumer.partitionsFor(Consts.superstreamMetadataTopic, Duration.ofMillis(10000));
if (partitions == null || partitions.isEmpty()) {
if (consumer != null) {
consumer.close();
}
return "0";
}
TopicPartition topicPartition = new TopicPartition(Consts.superstreamMetadataTopic, 0);
consumer.assign(Collections.singletonList(topicPartition));
consumer.seekToEnd(Collections.singletonList(topicPartition));
long endOffset = consumer.position(topicPartition);
if (endOffset > 0) {
consumer.seek(topicPartition, endOffset - 1);
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(10000));
if (!records.isEmpty()) {
connectionId = records.iterator().next().value();
}
}
} catch (Exception e2) {
handleError(String.format("consumeConnectionID retry: %s", e2.getMessage()));
}
}
if (connectionId == null || connectionId.equals("0")) {
handleError(String.format("consumeConnectionID: %s", e.getMessage()));
if (consumer != null) {
consumer.close();
}
return "0";
}
} finally {
if (consumer != null) {
consumer.close();
}
}
return connectionId != null ? connectionId : "0";
}
private Properties copyAuthConfig() {
String[] relevantKeys = {
// Authentication-related keys
"security.protocol",
"ssl.truststore.location",
"ssl.truststore.password",
"ssl.keystore.location",
"ssl.keystore.password",
"ssl.key.password",
"ssl.endpoint.identification.algorithm",
"sasl.mechanism",
"sasl.jaas.config",
"sasl.kerberos.service.name",
// Networking-related keys
"bootstrap.servers",
"client.dns.lookup",
"connections.max.idle.ms",
"request.timeout.ms",
"metadata.max.age.ms",
"reconnect.backoff.ms",
"reconnect.backoff.max.ms"
};
Properties relevantProps = new Properties();
for (String key : relevantKeys) {
if (configs.containsKey(key)) {
if (key == ProducerConfig.BOOTSTRAP_SERVERS_CONFIG) {
Object value = configs.get(key);
if (value instanceof String[]) {
relevantProps.put(key, Arrays.toString((String[]) value));
} else if (value instanceof ArrayList) {
@SuppressWarnings("unchecked")
ArrayList<String> arrayList = (ArrayList<String>) value;
relevantProps.put(key, String.join(", ", arrayList));
} else {
relevantProps.put(key, value);
}
} else {
relevantProps.put(key, String.valueOf(configs.get(key)));
}
}
}
return relevantProps;
}
public void sendClientTypeUpdateReq() {
if (type == "" || type == null) {
return;
}
if (type != "consumer" && type != "producer") {
return;
}
try {
Map<String, Object> reqData = new HashMap<>();
reqData.put("client_hash", clientHash);
reqData.put("type", type);
ObjectMapper mapper = new ObjectMapper();
byte[] reqBytes = mapper.writeValueAsBytes(reqData);
brokerConnection.publish(Consts.clientTypeUpdateSubject, reqBytes);
} catch (Exception e) {
handleError(String.format("sendClientTypeUpdateReq: %s", e.getMessage()));
}
}
public void subscribeToUpdates() {
try {
String subject = String.format(Consts.superstreamUpdatesSubject, clientHash);
Dispatcher dispatcher = brokerConnection.createDispatcher(this.updatesHandler());
updatesSubscription = dispatcher.subscribe(subject, this.updatesHandler());
} catch (Exception e) {
e.printStackTrace();
}
}
public void reportClientsUpdate() {
ScheduledExecutorService singleExecutorService = Executors.newSingleThreadScheduledExecutor();
singleExecutorService.scheduleAtFixedRate(() -> {
try {
if (brokerConnection != null && superstreamReady){
byte[] byteCounters = objectMapper.writeValueAsBytes(clientCounters);
AtomicReference<SuperstreamCounters> countersRef = clientCountersMap.get(clientHash);
if (countersRef != null) {
SuperstreamCounters currentCounters = countersRef.get();
if (currentCounters != null) {
byteCounters = objectMapper.writeValueAsBytes(currentCounters);
}
}
Map<String, Object> topicPartitionConfig = new HashMap<>();
if (!topicPartitions.isEmpty()) {
Map<String, Integer[]> topicPartitionsToSend = convertMap(topicPartitions);
switch (this.type) {
case "producer":
topicPartitionConfig.put("producer_topics_partitions", topicPartitionsToSend);
topicPartitionConfig.put("consumer_group_topics_partitions",
new HashMap<String, Integer[]>());
break;
case "consumer":
topicPartitionConfig.put("producer_topics_partitions", new HashMap<String, Integer[]>());
topicPartitionConfig.put("consumer_group_topics_partitions", topicPartitionsToSend);
break;
}
}
byte[] byteConfig = objectMapper.writeValueAsBytes(topicPartitionConfig);
brokerConnection.publish(String.format(Consts.superstreamClientsUpdateSubject, "counters", clientHash),
byteCounters);
brokerConnection.publish(String.format(Consts.superstreamClientsUpdateSubject, "config", clientHash),
byteConfig);
}
} catch (Exception e) {
handleError("reportClientsUpdate: " + e.getMessage());
}
}, 0, 10, TimeUnit.MINUTES);
}
public static Map<String, Integer[]> convertMap(Map<String, Set<Integer>> topicPartitions) {
Map<String, Integer[]> result = new HashMap<>();
for (Map.Entry<String, Set<Integer>> entry : topicPartitions.entrySet()) {
Integer[] array = entry.getValue().toArray(new Integer[0]);
result.put(entry.getKey(), array);
}
return result;
}
public void sendLearningMessage(byte[] msg) {
try {
brokerConnection.publish(String.format(Consts.superstreamLearningSubject, clientHash), msg);
} catch (Exception e) {
handleError("sendLearningMessage: " + e.getMessage());
}
}
public void sendRegisterSchemaReq() {
try {
brokerConnection.publish(String.format(Consts.superstreamRegisterSchemaSubject, clientHash), new byte[0]);
learningRequestSent = true;
} catch (Exception e) {
handleError("sendLearningMessage: " + e.getMessage());
}
}
public JsonToProtoResult jsonToProto(byte[] msgBytes) throws Exception {
try {
String jsonString = new String(msgBytes);
if (!isJsonObject(jsonString)) {
jsonString = convertEscapedJsonString(jsonString);
}
if (jsonString == null || jsonString.isEmpty()) {
return new JsonToProtoResult(false, msgBytes);
}
if (jsonString != null && jsonString.length() > 2 && jsonString.startsWith("\"{") && jsonString.endsWith("}\"")) {
jsonString = jsonString.substring(1, jsonString.length() - 1);
}
DynamicMessage.Builder newMessageBuilder = DynamicMessage.newBuilder(descriptor);
JsonFormat.parser().merge(jsonString, newMessageBuilder);
DynamicMessage message = newMessageBuilder.build();
return new JsonToProtoResult(true, message.toByteArray());
} catch (Exception e) {
return new JsonToProtoResult(false, msgBytes);
}
}
public class JsonToProtoResult {
private final boolean success;
private final byte[] messageBytes;
public JsonToProtoResult(boolean success, byte[] messageBytes) {
this.success = success;
this.messageBytes = messageBytes;
}
public boolean isSuccess() {
return success;
}
public byte[] getMessageBytes() {
return messageBytes;
}
}
private boolean isJsonObject(String jsonString) {
try {
JsonParser.parseString(jsonString).getAsJsonObject();
return true;
} catch (JsonSyntaxException | IllegalStateException e) {
return false;
}
}
private static String convertEscapedJsonString(String escapedJsonString) throws Exception {
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(escapedJsonString);
return mapper.writeValueAsString(jsonNode).replace("\\\"", "\"").replace("\\\\", "\\");
}
public byte[] protoToJson(byte[] msgBytes, Descriptors.Descriptor desc) throws Exception {
try {
DynamicMessage message = DynamicMessage.parseFrom(desc, msgBytes);
String jsonString = JsonFormat.printer().omittingInsignificantWhitespace().print(message);
return jsonString.getBytes(StandardCharsets.UTF_8);
} catch (Exception e) {
if (e.getMessage().contains("the input ended unexpectedly")) {
return msgBytes;
} else {
throw e;
}
}
}
private MessageHandler updatesHandler() {
return (msg) -> {
try {
@SuppressWarnings("unchecked")
Map<String, Object> update = objectMapper.readValue(msg.getData(), Map.class);
processUpdate(update);
} catch (IOException e) {
handleError("updatesHandler at json.Unmarshal: " + e.getMessage());
}
};
}
private void processUpdate(Map<String, Object> update) {
String type = (String) update.get("type");
try {
String payloadBytesString = (String) update.get("payload");
byte[] payloadBytes = Base64.getDecoder().decode(payloadBytesString);
@SuppressWarnings("unchecked")
Map<String, Object> payload = objectMapper.readValue(payloadBytes, Map.class);
switch (type) {
case "LearnedSchema":
String descriptorBytesString = (String) payload.get("desc");
String masterMsgName = (String) payload.get("master_msg_name");
String fileName = (String) payload.get("file_name");
descriptor = compileMsgDescriptor(descriptorBytesString, masterMsgName, fileName);
String schemaID = (String) payload.get("schema_id");
ProducerSchemaID = schemaID;
break;
case "ToggleReduction":
Boolean enableReduction = (Boolean) payload.get("enable_reduction");
if (enableReduction) {
this.reductionEnabled = true;
} else {
this.reductionEnabled = false;
}
break;
case "CompressionUpdate":
Boolean enableCompression = (Boolean) payload.get("enable_compression");
String compressionType = (String) payload.get("compression_type");
this.compressionEnabled = enableCompression;
if (compressionUpdateCallback != null) {
compressionUpdateCallback.onCompressionUpdate(enableCompression, compressionType);
}
break;
}
} catch (Exception e) {
handleError(("processUpdate: " + e.getMessage()));
}
}
public void sendGetSchemaRequest(String schemaID) {
try {
Map<String, Object> reqData = new HashMap<>();
reqData.put("schema_id", schemaID);
ObjectMapper mapper = new ObjectMapper();
byte[] reqBytes = mapper.writeValueAsBytes(reqData);
Message msg = brokerConnection.request(String.format(Consts.superstreamGetSchemaSubject, clientHash),
reqBytes, Duration.ofSeconds(5));
if (msg == null) {
throw new Exception("Could not get descriptor");
}
@SuppressWarnings("unchecked")
Map<String, Object> respMap = objectMapper.readValue(new String(msg.getData(), StandardCharsets.UTF_8),
Map.class);
if (respMap.containsKey("desc") && respMap.get("desc") instanceof String) {
String descriptorBytesString = (String) respMap.get("desc");
String masterMsgName = (String) respMap.get("master_msg_name");
String fileName = (String) respMap.get("file_name");
Descriptors.Descriptor respDescriptor = compileMsgDescriptor(descriptorBytesString, masterMsgName,
fileName);
if (respDescriptor != null) {
SchemaIDMap.put((String) respMap.get("schema_id"), respDescriptor);
} else {
throw new Exception("Error compiling schema.");
}
} else {
throw new Exception("Response map does not contain expected keys.");
}
} catch (Exception e) {
handleError(String.format("sendGetSchemaRequest: %s", e.getMessage()));
}
}
private Descriptors.Descriptor compileMsgDescriptor(String descriptorBytesString, String masterMsgName,
String fileName) {
try {
byte[] descriptorAsBytes = Base64.getDecoder().decode(descriptorBytesString);
if (descriptorAsBytes == null) {
throw new Exception("error decoding descriptor bytes");
}
FileDescriptorSet descriptorSet = FileDescriptorSet.parseFrom(descriptorAsBytes);
FileDescriptor fileDescriptor = null;
for (DescriptorProtos.FileDescriptorProto fdp : descriptorSet.getFileList()) {
if (fdp.getName().equals(fileName)) {
fileDescriptor = FileDescriptor.buildFrom(fdp, new FileDescriptor[] {});
break;
}
}
if (fileDescriptor == null) {
throw new Exception("file not found");
}
for (Descriptors.Descriptor md : fileDescriptor.getMessageTypes()) {
if (md.getName().equals(masterMsgName)) {
return md;
}
}
} catch (Exception e) {
handleError(String.format("compileMsgDescriptor: %s", e.getMessage()));
}
return null;
}
public void handleError(String msg) {
if (brokerConnection != null && superstreamReady) {
Map<String, String> envVars = System.getenv();
String tags = envVars.get("SUPERSTREAM_TAGS");
if (tags == null) {
tags = "";
}
if (clientHash == "") {
String message = String.format("[sdk: java][version: %s][tags: %s] %s", Consts.sdkVersion, tags, msg);
brokerConnection.publish(Consts.superstreamErrorSubject, message.getBytes(StandardCharsets.UTF_8));
} else {
String message = String.format("[clientHash: %s][sdk: java][version: %s][tags: %s] %s",
clientHash, Consts.sdkVersion, tags, msg);
brokerConnection.publish(Consts.superstreamErrorSubject, message.getBytes(StandardCharsets.UTF_8));
}
}
}
public static Map<String, Object> normalizeClientConfig(Map<String, ?> javaConfig) {
Map<String, Object> superstreamConfig = new HashMap<>();
// Producer configurations
// Note: Handling of `producer_return_errors` and `producer_return_successes` is
// typically done programmatically in the Java client,
// `producer_flush_max_messages` does not exist in java
mapIfPresent(javaConfig, ProducerConfig.MAX_REQUEST_SIZE_CONFIG, superstreamConfig,
"producer_max_messages_bytes");
mapIfPresent(javaConfig, ProducerConfig.ACKS_CONFIG, superstreamConfig, "producer_required_acks");
mapIfPresent(javaConfig, ProducerConfig.DELIVERY_TIMEOUT_MS_CONFIG, superstreamConfig, "producer_timeout");
mapIfPresent(javaConfig, ProducerConfig.RETRIES_CONFIG, superstreamConfig, "producer_retry_max");
mapIfPresent(javaConfig, ProducerConfig.RETRY_BACKOFF_MS_CONFIG, superstreamConfig, "producer_retry_backoff");
mapIfPresent(javaConfig, ProducerConfig.COMPRESSION_TYPE_CONFIG, superstreamConfig,
"producer_compression_level");
// Consumer configurations
// Note: `consumer_return_errors`, `consumer_offsets_initial`,
// `consumer_offsets_retry_max`, `consumer_group_rebalance_timeout`,
// `consumer_group_rebalance_retry_max` does not exist in java
mapIfPresent(javaConfig, ConsumerConfig.FETCH_MIN_BYTES_CONFIG, superstreamConfig, "consumer_fetch_min");
mapIfPresent(javaConfig, ConsumerConfig.FETCH_MAX_BYTES_CONFIG, superstreamConfig, "consumer_fetch_default");
mapIfPresent(javaConfig, ConsumerConfig.RETRY_BACKOFF_MS_CONFIG, superstreamConfig, "consumer_retry_backoff");
mapIfPresent(javaConfig, ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, superstreamConfig,
"consumer_max_wait_time");
mapIfPresent(javaConfig, ConsumerConfig.MAX_POLL_RECORDS_CONFIG, superstreamConfig,
"consumer_max_processing_time");
// mapIfPresent(javaConfig, ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG,
// superstreamConfig, "consumer_offset_auto_commit_enable");
// TODO: handle boolean vars
mapIfPresent(javaConfig, ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, superstreamConfig,
"consumer_offset_auto_commit_interval");
mapIfPresent(javaConfig, ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, superstreamConfig,
"consumer_group_session_timeout");
mapIfPresent(javaConfig, ConsumerConfig.HEARTBEAT_INTERVAL_MS_CONFIG, superstreamConfig,
"consumer_group_heart_beat_interval");
mapIfPresent(javaConfig, ConsumerConfig.RETRY_BACKOFF_MS_CONFIG, superstreamConfig,
"consumer_group_rebalance_retry_back_off");
// mapIfPresent(javaConfig, ConsumerConfig.AUTO_OFFSET_RESET_CONFIG ,
// superstreamConfig, "consumer_group_rebalance_reset_invalid_offsets"); //
// TODO: handle boolean vars
mapIfPresent(javaConfig, ConsumerConfig.GROUP_ID_CONFIG, superstreamConfig, "consumer_group_id");
// Common configurations
mapIfPresent(javaConfig, ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, superstreamConfig, "servers");
// Note: No access to `producer_topics_partitions` and
// `consumer_group_topics_partitions`
return superstreamConfig;
}
private static void mapIfPresent(Map<String, ?> javaConfig, String javaKey, Map<String, Object> superstreamConfig,
String superstreamKey) {
if (javaConfig.containsKey(javaKey)) {
if (javaKey == ProducerConfig.BOOTSTRAP_SERVERS_CONFIG) {
Object value = javaConfig.get(javaKey);
if (value instanceof String[]) {
superstreamConfig.put(superstreamKey, Arrays.toString((String[]) value));
} else if (value instanceof ArrayList) {
@SuppressWarnings("unchecked")
ArrayList<String> arrayList = (ArrayList<String>) value;
superstreamConfig.put(superstreamKey, String.join(", ", arrayList));
} else {
superstreamConfig.put(superstreamKey, value);
}
} else {
superstreamConfig.put(superstreamKey, javaConfig.get(javaKey));
}
}
}
public static Map<String, Object> initSuperstreamConfig(Map<String, Object> configs, String type) {
String isInnerConsumer = (String) configs.get(Consts.superstreamInnerConsumerKey);
if (isInnerConsumer != null && isInnerConsumer.equals("true")) {
return configs;
}
String interceptorToAdd = "";
switch (type) {
case "producer":
interceptorToAdd = SuperstreamProducerInterceptor.class.getName();
if (configs.containsKey(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG)) {
if (!configs.containsKey(Consts.originalSerializer)) {
configs.put(Consts.originalSerializer,
configs.get(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG));
configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
SuperstreamSerializer.class.getName());
}
}
break;
case "consumer":
interceptorToAdd = SuperstreamConsumerInterceptor.class.getName();
if (configs.containsKey(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG)) {
if (!configs.containsKey(Consts.originalDeserializer)) {
configs.put(Consts.originalDeserializer,
configs.get(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG));
configs.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
SuperstreamDeserializer.class.getName());
}
}
break;
}
try {
List<String> interceptors = null;
Object existingInterceptors = configs.get(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG);
if (interceptorToAdd != "") {
if (existingInterceptors != null) {
if (existingInterceptors instanceof List) {
interceptors = new ArrayList<>((List<String>) existingInterceptors);
} else if (existingInterceptors instanceof String) {
interceptors = new ArrayList<>();
interceptors.add((String) existingInterceptors);
} else {
interceptors = new ArrayList<>();
}
} else {
interceptors = new ArrayList<>();
}
}
if (interceptorToAdd != "") {
interceptors.add(interceptorToAdd);
configs.put(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, interceptors);
}
Map<String, String> envVars = System.getenv();
String superstreamHost = envVars.get("SUPERSTREAM_HOST");
if (superstreamHost == null) {
throw new Exception("host is required");
}
configs.put(Consts.superstreamHostKey, superstreamHost);
String token = envVars.get("SUPERSTREAM_TOKEN");
if (token == null) {
token = Consts.superstreamDefaultToken;
}
configs.put(Consts.superstreamTokenKey, token);
String learningFactorString = envVars.get("SUPERSTREAM_LEARNING_FACTOR");
Integer learningFactor = Consts.superstreamDefaultLearningFactor;
if (learningFactorString != null) {
learningFactor = Integer.parseInt(learningFactorString);
}
configs.put(Consts.superstreamLearningFactorKey, learningFactor);
Boolean reductionEnabled = false;
String reductionEnabledString = envVars.get("SUPERSTREAM_REDUCTION_ENABLED");
if (reductionEnabledString != null) {
reductionEnabled = Boolean.parseBoolean(reductionEnabledString);
}
configs.put(Consts.superstreamReductionEnabledKey, reductionEnabled);
String tags = envVars.get("SUPERSTREAM_TAGS");
if (tags == null) {
tags = "";
}
Superstream superstreamConnection = new Superstream(token, superstreamHost, learningFactor, configs,
reductionEnabled, type, tags);
superstreamConnection.init();
configs.put(Consts.superstreamConnectionKey, superstreamConnection);
} catch (Exception e) {
String errMsg = String.format("superstream: error initializing superstream: %s", e.getMessage());
System.out.println(errMsg);
switch (type) {
case "producer":
if (configs.containsKey(Consts.originalSerializer)) {
configs.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
configs.get(Consts.originalSerializer));
configs.remove(Consts.originalSerializer);
}
break;
case "consumer":
if (configs.containsKey(Consts.originalDeserializer)) {
configs.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
configs.get(Consts.originalDeserializer));
configs.remove(Consts.originalDeserializer);
}
break;
}
}
return configs;
}
public static Properties initSuperstreamProps(Properties properties, String type) {
String interceptors = (String) properties.get(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG);
switch (type) {
case "producer":
if (interceptors != null && !interceptors.isEmpty()) {
interceptors += "," + SuperstreamProducerInterceptor.class.getName();
} else {
interceptors = SuperstreamProducerInterceptor.class.getName();
}
if (properties.containsKey(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG)) {
if (!properties.containsKey(Consts.originalSerializer)) {
properties.put(Consts.originalSerializer,
properties.get(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG));
properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,
SuperstreamSerializer.class.getName());
}
}
break;
case "consumer":
if (interceptors != null && !interceptors.isEmpty()) {
interceptors += "," + SuperstreamConsumerInterceptor.class.getName();
} else {
interceptors = SuperstreamConsumerInterceptor.class.getName();
}
if (properties.containsKey(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG)) {
if (!properties.containsKey(Consts.originalDeserializer)) {
properties.put(Consts.originalDeserializer,
properties.get(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG));
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG,
SuperstreamDeserializer.class.getName());
}
}
break;
}
if (interceptors != null) {
properties.put(ProducerConfig.INTERCEPTOR_CLASSES_CONFIG, interceptors);
}
try {
Map<String, String> envVars = System.getenv();
String superstreamHost = envVars.get("SUPERSTREAM_HOST");
if (superstreamHost == null) {
throw new Exception("host is required");
}
properties.put(Consts.superstreamHostKey, superstreamHost);
String token = envVars.get("SUPERSTREAM_TOKEN");
if (token == null) {
token = Consts.superstreamDefaultToken;
}
properties.put(Consts.superstreamTokenKey, token);
String learningFactorString = envVars.get("SUPERSTREAM_LEARNING_FACTOR");
Integer learningFactor = Consts.superstreamDefaultLearningFactor;
if (learningFactorString != null) {
learningFactor = Integer.parseInt(learningFactorString);
}
properties.put(Consts.superstreamLearningFactorKey, learningFactor);
Boolean reductionEnabled = false;
String reductionEnabledString = envVars.get("SUPERSTREAM_REDUCTION_ENABLED");
if (reductionEnabledString != null) {
reductionEnabled = Boolean.parseBoolean(reductionEnabledString);
}
properties.put(Consts.superstreamReductionEnabledKey, reductionEnabled);
String tags = envVars.get("SUPERSTREAM_TAGS");
if (tags != null) {
properties.put(Consts.superstreamTagsKey, tags);
}
Map<String, Object> configs = propertiesToMap(properties);
Superstream superstreamConnection = new Superstream(token, superstreamHost, learningFactor, configs,
reductionEnabled, type);
superstreamConnection.init();
properties.put(Consts.superstreamConnectionKey, superstreamConnection);
} catch (Exception e) {
String errMsg = String.format("superstream: error initializing superstream: %s", e.getMessage());
System.out.println(errMsg);
}
return properties;
}
public static Map<String, Object> propertiesToMap(Properties properties) {
return properties.entrySet().stream()
.collect(Collectors.toMap(
e -> String.valueOf(e.getKey()),
e -> e.getValue()));
}
public void updateTopicPartitions(String topic, Integer partition) {
Set<Integer> partitions = topicPartitions.computeIfAbsent(topic, k -> new HashSet<>());
if (!partitions.contains(partition)) {
partitions.add(partition);
}
}
}
|
0 | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai/superstream/SuperstreamConsumerInterceptor.java | package ai.superstream;
import java.util.Map;
import org.apache.kafka.clients.consumer.ConsumerInterceptor;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.OffsetAndMetadata;
import org.apache.kafka.common.TopicPartition;
public class SuperstreamConsumerInterceptor<K, V> implements ConsumerInterceptor<K, V> {
Superstream superstreamConnection;
public SuperstreamConsumerInterceptor(){}
@Override
public ConsumerRecords<K, V> onConsume(ConsumerRecords<K, V> records) {
if (this.superstreamConnection != null) {
if (!records.isEmpty()) {
ConsumerRecord<K, V> firstRecord = records.iterator().next();
this.superstreamConnection.updateTopicPartitions(firstRecord.topic(), firstRecord.partition());
}
};
return records;
}
@Override
public void onCommit(Map<TopicPartition, OffsetAndMetadata> offsets) {
}
@Override
public void close() {
}
@Override
public void configure(Map<String, ?> configs) {
Superstream superstreamConn = (Superstream) configs.get(Consts.superstreamConnectionKey);
if (superstreamConn != null) {
this.superstreamConnection = superstreamConn;
}
}
}
|
0 | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai/superstream/SuperstreamCounters.java | package ai.superstream;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
public class SuperstreamCounters {
@JsonProperty("total_bytes_before_reduction")
public AtomicLong TotalBytesBeforeReduction = new AtomicLong(0);
@JsonProperty("total_bytes_after_reduction")
public AtomicLong TotalBytesAfterReduction = new AtomicLong(0);
@JsonProperty("total_messages_successfully_produce")
public AtomicInteger TotalMessagesSuccessfullyProduce = new AtomicInteger(0);
@JsonProperty("total_messages_successfully_consume")
public AtomicInteger TotalMessagesSuccessfullyConsumed = new AtomicInteger(0);
@JsonProperty("total_messages_failed_produce")
public AtomicInteger TotalMessagesFailedProduce = new AtomicInteger(0);
@JsonProperty("total_messages_failed_consume")
public AtomicInteger TotalMessagesFailedConsume = new AtomicInteger(0);
@JsonProperty("total_serialization_reduced")
public AtomicLong TotalSSMPayloadReduced = new AtomicLong(0);
public SuperstreamCounters() {
}
public void reset() {
TotalBytesBeforeReduction = new AtomicLong(0);
TotalBytesAfterReduction = new AtomicLong(0);
TotalSSMPayloadReduced = new AtomicLong(0);
TotalMessagesSuccessfullyProduce = new AtomicInteger(0);
TotalMessagesSuccessfullyConsumed = new AtomicInteger(0);
TotalMessagesFailedProduce = new AtomicInteger(0);
TotalMessagesFailedConsume = new AtomicInteger(0);
}
public void incrementTotalBytesBeforeReduction(long bytes) {
TotalBytesBeforeReduction.addAndGet(bytes);
}
public void incrementTotalBytesAfterReduction(long bytes) {
TotalBytesAfterReduction.addAndGet(bytes);
}
public void incrementTotalSSMPayloadReduced(long bytes) {
TotalSSMPayloadReduced.addAndGet(bytes);
}
public void incrementTotalMessagesSuccessfullyProduce() {
TotalMessagesSuccessfullyProduce.incrementAndGet();
}
public void sumTotalBeforeReductionTotalSSMPayloadReduced() {
long valueToAdd = TotalSSMPayloadReduced.getAndSet(0);
TotalBytesBeforeReduction.addAndGet(valueToAdd);
}
public void incrementTotalMessagesSuccessfullyConsumed() {
TotalMessagesSuccessfullyConsumed.incrementAndGet();
}
public void incrementTotalMessagesFailedProduce() {
TotalMessagesFailedProduce.incrementAndGet();
}
public void incrementTotalMessagesFailedConsume() {
TotalMessagesFailedConsume.incrementAndGet();
}
public long getTotalBytesBeforeReduction() {
return TotalBytesBeforeReduction.get();
}
public long getTotalBytesAfterReduction() {
return TotalBytesAfterReduction.get();
}
public int getTotalMessagesSuccessfullyProduce() {
return TotalMessagesSuccessfullyProduce.get();
}
public int getTotalMessagesSuccessfullyConsumed() {
return TotalMessagesSuccessfullyConsumed.get();
}
public int getTotalMessagesFailedProduce() {
return TotalMessagesFailedProduce.get();
}
public int getTotalMessagesFailedConsume() {
return TotalMessagesFailedConsume.get();
}
public void setTotalBytesBeforeReduction(long totalBytesBeforeReduction) {
TotalBytesBeforeReduction = new AtomicLong(totalBytesBeforeReduction);
}
public void setTotalBytesAfterReduction(long totalBytesAfterReduction) {
TotalBytesAfterReduction = new AtomicLong(totalBytesAfterReduction);
}
public void setTotalMessagesSuccessfullyProduce(int totalMessagesSuccessfullyProduce) {
TotalMessagesSuccessfullyProduce.addAndGet(totalMessagesSuccessfullyProduce);
}
public void setTotalMessagesSuccessfullyConsumed(int totalMessagesSuccessfullyConsumed) {
TotalMessagesSuccessfullyConsumed.addAndGet(totalMessagesSuccessfullyConsumed);
}
public void setTotalMessagesFailedProduce(int totalMessagesFailedProduce) {
TotalMessagesFailedProduce.addAndGet(totalMessagesFailedProduce);
}
public void setTotalMessagesFailedConsume(int totalMessagesFailedConsume) {
TotalMessagesFailedConsume.addAndGet(totalMessagesFailedConsume);
}
}
|
0 | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai/superstream/SuperstreamDeserializer.java | package ai.superstream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import org.apache.kafka.common.serialization.Deserializer;
import com.google.protobuf.Descriptors;
import org.apache.kafka.common.header.Header;
import org.apache.kafka.common.header.Headers;
public class SuperstreamDeserializer<T> implements Deserializer<T> {
private Deserializer<T> originalDeserializer;
private Superstream superstreamConnection;
public SuperstreamDeserializer() {
}
@Override
public void configure(Map<String, ?> configs, boolean isKey) {
try {
Object originalDeserializerObj = configs.get(Consts.originalDeserializer);
if (originalDeserializerObj == null) {
throw new Exception("original deserializer is required");
}
Class<?> originalDeserializerClass;
if (originalDeserializerObj instanceof String) {
originalDeserializerClass = Class.forName((String) originalDeserializerObj);
} else if (originalDeserializerObj instanceof Class) {
originalDeserializerClass = (Class<?>) originalDeserializerObj;
} else {
throw new Exception("Invalid type for original deserializer");
}
@SuppressWarnings("unchecked")
Deserializer<T> originalDeserializerT = (Deserializer<T>) originalDeserializerClass.getDeclaredConstructor()
.newInstance();
this.originalDeserializer = originalDeserializerT;
this.originalDeserializer.configure(configs, isKey);
Superstream superstreamConn = (Superstream) configs.get(Consts.superstreamConnectionKey);
if (superstreamConn == null) {
System.out.println("Failed to connect to Superstream");
} else {
this.superstreamConnection = superstreamConn;
}
} catch (Exception e) {
String errMsg = String.format("superstream: error initializing superstream: %s", e.getMessage());
if (superstreamConnection != null) {
superstreamConnection.handleError(errMsg);
}
System.out.println(errMsg);
}
}
@Override
public T deserialize(String topic, byte[] data) {
if (originalDeserializer == null) {
return null;
}
T deserializedData = originalDeserializer.deserialize(topic, data);
return deserializedData;
}
@Override
public T deserialize(String topic, Headers headers, byte[] data) {
if (originalDeserializer == null) {
return null;
}
String schemaId = null;
Header header = headers.lastHeader("superstream_schema");
if (header != null) {
schemaId = new String(header.value(), StandardCharsets.UTF_8);
}
byte[] dataToDesrialize = data;
if (dataToDesrialize == null) {
this.originalDeserializer.deserialize(topic, headers, dataToDesrialize);
}
if (this.superstreamConnection != null) {
superstreamConnection.updateClientCounters(counters -> {
counters.incrementTotalBytesAfterReduction(data.length);
});
}
if (schemaId != null) {
if (!this.superstreamConnection.superstreamReady) {
int totalWaitTime = 60;
int checkInterval = 5;
try {
for (int i = 0; i < totalWaitTime; i += checkInterval) {
if (this.superstreamConnection.superstreamReady) {
break;
}
Thread.sleep(checkInterval * 1000);
}
} catch (Exception e) {}
}
if (!this.superstreamConnection.superstreamReady) {
System.out.println("superstream: cannot connect with superstream and consume message that was modified by superstream");
return null;
}
Descriptors.Descriptor desc = superstreamConnection.SchemaIDMap.get(schemaId);
if (desc == null) {
superstreamConnection.sendGetSchemaRequest(schemaId);
desc = superstreamConnection.SchemaIDMap.get(schemaId);
if (desc == null) {
superstreamConnection.handleError("error getting schema with id: " + schemaId);
System.out.println("superstream: shcema not found");
return null;
}
}
try {
byte[] supertstreamDeserialized = superstreamConnection.protoToJson(data, desc);
dataToDesrialize = supertstreamDeserialized;
superstreamConnection.updateClientCounters(counters -> {
counters.incrementTotalBytesBeforeReduction(supertstreamDeserialized.length);
counters.incrementTotalMessagesSuccessfullyConsumed();
});
} catch (Exception e) {
superstreamConnection.handleError(String.format("error deserializing data: %s", e.getMessage()));
return null;
}
} else {
if (superstreamConnection != null) {
superstreamConnection.updateClientCounters(counters -> {
counters.incrementTotalBytesBeforeReduction(data.length);
counters.incrementTotalMessagesFailedConsume();
});
}
}
T deserializedData = this.originalDeserializer.deserialize(topic, headers, dataToDesrialize);
return deserializedData;
}
@Override
public void close() {
if (originalDeserializer != null) {
originalDeserializer.close();
}
if (superstreamConnection != null) {
superstreamConnection.close();
}
}
}
|
0 | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai/superstream/SuperstreamProducerInterceptor.java | package ai.superstream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import org.apache.kafka.clients.producer.ProducerInterceptor;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.apache.kafka.common.header.Header;
import org.apache.kafka.common.header.Headers;
public class SuperstreamProducerInterceptor<K, V> implements ProducerInterceptor<K, V> {
Superstream superstreamConnection;
public SuperstreamProducerInterceptor() {}
@Override
public ProducerRecord<K, V> onSend(ProducerRecord<K, V> record) {
if (this.superstreamConnection != null) {
if (record != null) {
this.superstreamConnection.updateTopicPartitions(record.topic(), record.partition());
}
}
return record;
}
@Override
public void onAcknowledgement(RecordMetadata metadata, Exception exception) {
}
@Override
public void close() {
}
@Override
public void configure(Map<String, ?> configs) {
Superstream superstreamConn = (Superstream) configs.get(Consts.superstreamConnectionKey);
if (superstreamConn != null) {
this.superstreamConnection = superstreamConn;
}
}
}
|
0 | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai | java-sources/ai/superstream/superstream-java/1.0.12-beta16/ai/superstream/SuperstreamSerializer.java | package ai.superstream;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.header.Header;
import org.apache.kafka.common.header.Headers;
import org.apache.kafka.common.header.internals.RecordHeader;
import org.apache.kafka.common.serialization.Serializer;
import ai.superstream.Superstream.JsonToProtoResult;
public class SuperstreamSerializer<T> implements Serializer<T> {
private Serializer<T> originalSerializer;
private Superstream superstreamConnection;
private volatile String compressionType = "none";
private boolean producerCompressionEnabled = false;
public SuperstreamSerializer() {
}
@Override
public void configure(Map<String, ?> configs, boolean isKey) {
try {
Object originalSerializerObj = configs.get(Consts.originalSerializer);
if (originalSerializerObj == null) {
throw new Exception("Original serializer is required");
}
Class<?> originalSerializerClass;
if (originalSerializerObj instanceof String) {
originalSerializerClass = Class.forName((String) originalSerializerObj);
} else if (originalSerializerObj instanceof Class) {
originalSerializerClass = (Class<?>) originalSerializerObj;
} else {
throw new Exception("Invalid type for original serializer");
}
@SuppressWarnings("unchecked")
Serializer<T> originalSerializerT = (Serializer<T>) originalSerializerClass.getDeclaredConstructor()
.newInstance();
this.originalSerializer = originalSerializerT;
this.originalSerializer.configure(configs, isKey);
Superstream superstreamConn = (Superstream) configs.get(Consts.superstreamConnectionKey);
if (superstreamConn == null) {
System.out.println("Failed to connect to Superstream");
} else {
this.superstreamConnection = superstreamConn;
}
String configuredCompressionType = (String) configs.get(ProducerConfig.COMPRESSION_TYPE_CONFIG);
this.producerCompressionEnabled = configuredCompressionType != null && !configuredCompressionType.equals("none");
if (this.superstreamConnection != null) {
this.superstreamConnection.setCompressionUpdateCallback(this::onCompressionUpdate);
this.compressionType = this.superstreamConnection.compressionEnabled ? "zstd" : "none";
}
this.compressionType = this.producerCompressionEnabled ? configuredCompressionType : "none";
} catch (Exception e) {
String errMsg = String.format("Superstream: Error initializing serializer: %s", e.getMessage());
if (superstreamConnection != null) {
superstreamConnection.handleError(errMsg);
}
System.out.println(errMsg);
}
}
private void onCompressionUpdate(boolean enabled, String type) {
if (!this.producerCompressionEnabled) {
this.compressionType = enabled ? type : "none";
}
}
@Override
public byte[] serialize(String topic, T data) {
byte[] serializedData = originalSerializer.serialize(topic, data);
return serializedData;
}
@Override
public byte[] serialize(String topic, Headers headers, T data) {
if (originalSerializer == null) {
return null;
}
byte[] serializedData = this.originalSerializer.serialize(topic, headers, data);
byte[] serializedResult = serializedData;
if (serializedData == null) {
return null;
}
if (superstreamConnection != null && superstreamConnection.superstreamReady) {
int inputLength = serializedData.length;
if (superstreamConnection.reductionEnabled && superstreamConnection.descriptor != null) {
try {
JsonToProtoResult jsonToProtoResult = superstreamConnection.jsonToProto(serializedData);
if (jsonToProtoResult.isSuccess()) {
serializedResult = jsonToProtoResult.getMessageBytes();
superstreamConnection.updateClientCounters(counters ->
counters.incrementTotalMessagesSuccessfullyProduce());
Header header = new RecordHeader("superstream_schema",
superstreamConnection.ProducerSchemaID.getBytes(StandardCharsets.UTF_8));
headers.add(header);
}
} catch (Exception e) {
superstreamConnection.handleError(String.format("error serializing data: %s", e.getMessage()));
superstreamConnection.updateClientCounters(counters ->
counters.incrementTotalMessagesFailedProduce());
}
long reducedBytes = inputLength - serializedResult.length;
superstreamConnection.updateClientCounters(counters ->
counters.incrementTotalSSMPayloadReduced(reducedBytes));
} else if (superstreamConnection.reductionEnabled) {
if (superstreamConnection.learningFactorCounter <= superstreamConnection.learningFactor) {
superstreamConnection.sendLearningMessage(serializedData);
superstreamConnection.learningFactorCounter++;
} else if (!superstreamConnection.learningRequestSent) {
superstreamConnection.sendRegisterSchemaReq();
}
}
if (superstreamConnection.compressionEnabled && !producerCompressionEnabled) {
headers.add(new RecordHeader("superstream-compression", "on".getBytes(StandardCharsets.UTF_8)));
}
}
return serializedResult;
}
@Override
public void close() {
if (this.originalSerializer != null) {
originalSerializer.close();
}
if (superstreamConnection != null) {
superstreamConnection.close();
}
}
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/AppConstants.java | package com.swaasa.swaasaplatform;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
public class AppConstants {
public static final String root_url = "https://swaasa.sandbox.swaasa.ai/api/"; //test environment
// public static final String root_url = "http://192.168.0.101:8000/api/"; //local environment
/** Time interval for Recording progress visualisation. */
public final static int RECORDING_VISUALIZATION_INTERVAL = 13; //mills
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/Assessment.java | package com.swaasa.swaasaplatform;
import com.google.gson.Gson;
import com.swaasa.swaasaplatform.apis.APIService;
import com.swaasa.swaasaplatform.model.BaseResponse;
import com.swaasa.swaasaplatform.model.Gender;
import com.swaasa.swaasaplatform.model.PredictionResponse;
import com.swaasa.swaasaplatform.model.Symptoms;
import com.swaasa.swaasaplatform.model.VerifyCoughResponse;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import timber.log.Timber;
public class Assessment {
APIService apiService;
RestCallback restCallback;
public Assessment(String apiKey, RestCallback restCallback){
this.restCallback = restCallback;
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); //for
OkHttpClient.Builder client = new OkHttpClient.Builder();
client.addInterceptor(new Interceptor() {
@Override
public okhttp3.Response intercept(Chain chain) throws IOException {
Request original = chain.request();
Request request = original.newBuilder()
.header("Content-Type", "application/x-www-form-urlencoded")
.header("x-api-key", apiKey)
.method(original.method(), original.body())
.build();
return chain.proceed(request);
}
});
client.interceptors().add(interceptor);
client.connectTimeout(120, TimeUnit.SECONDS);
client.readTimeout(60, TimeUnit.SECONDS);
client.writeTimeout(60, TimeUnit.SECONDS);
apiService = new Retrofit.Builder().baseUrl(AppConstants.root_url)
.client(client.build())
.addConverterFactory(GsonConverterFactory.create())
.build().create(APIService.class);
}
public void verifyCough(File coughFile){
retrofit2.Call<VerifyCoughResponse> request;
RequestBody requestFile =
RequestBody.create(coughFile,
MediaType.parse("audio/*"));
MultipartBody.Part cough_body = MultipartBody.Part.createFormData("coughsoundfile", coughFile.getName(), requestFile);
request = apiService.verifyCough(cough_body);
Gson gson = new Gson();
request.enqueue(new Callback<VerifyCoughResponse>() {
@Override
public void onResponse(Call<VerifyCoughResponse> call, Response<VerifyCoughResponse> response) {
if (response.isSuccessful()) {
if (response.code() == 200) {
VerifyCoughResponse response1 = response.body();
restCallback.onSuccess(response1);
}else{
BaseResponse response1 = gson.fromJson(response.body().toString(), BaseResponse.class);
restCallback.onFailure(response1);
}
}}
@Override
public void onFailure(Call<VerifyCoughResponse> call, Throwable t) {
BaseResponse baseResponse = new BaseResponse();
baseResponse.setStatus("ERROR");
baseResponse.setMessage(t.getMessage());
restCallback.onFailure(baseResponse);
}
});
}
public void submitAssessment(File coughFile, Symptoms symptoms, int age, Gender gender){
retrofit2.Call<PredictionResponse> request;
RequestBody requestFile =
RequestBody.create(coughFile,
MediaType.parse("audio/*"));
Gson gson = new Gson();
MultipartBody.Part cough_body = MultipartBody.Part.createFormData("coughsoundfile", coughFile.getName(), requestFile);
RequestBody symptomsBody = RequestBody.create(okhttp3.MediaType.parse("text/plain"),
gson.toJson(symptoms));
RequestBody ageBody = RequestBody.create(okhttp3.MediaType.parse("text/plain"),
String.valueOf(age));
RequestBody genderBody = RequestBody.create(okhttp3.MediaType.parse("text/plain"),
String.valueOf(gender.getValue()));
RequestBody assessmentIdBody = RequestBody.create(okhttp3.MediaType.parse("text/plain"),
"some_id");
request = apiService.predict(cough_body,symptomsBody,ageBody, genderBody, assessmentIdBody );
request.enqueue(new Callback<PredictionResponse>() {
@Override
public void onResponse(Call<PredictionResponse> call, Response<PredictionResponse> response) {
if (response.isSuccessful()) {
if (response.code() == 200) {
restCallback.onSuccess(response.body());
} else {
BaseResponse response1 = gson.fromJson(response.body().toString(), BaseResponse.class);
restCallback.onFailure(response1);
}
}
}
@Override
public void onFailure(Call<PredictionResponse> call, Throwable t) {
BaseResponse baseResponse = new BaseResponse();
baseResponse.setStatus("ERROR");
baseResponse.setMessage(t.getMessage());
restCallback.onFailure(baseResponse);
}
});
}
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/CoughRecorder.java | package com.swaasa.swaasaplatform;
import android.annotation.SuppressLint;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import timber.log.Timber;
public class CoughRecorder {
File filePath = null;
final int bpp = 16;
int sampleRate = 44100;
private int channelCount = 1;
int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
AudioRecord recorder = null;
int bufferSize = 0;
Thread recordingThread;
boolean isRecording = false;
public CoughRecorder(File path){
filePath = path;
}
private void writeAudioDataToFile() {
byte[] data = new byte[bufferSize];
FileOutputStream fos;
try {
fos = new FileOutputStream(filePath);
} catch (FileNotFoundException e) {
Timber.e(e);
fos = null;
}
if (null != fos) {
int chunksCount = 0;
ByteBuffer shortBuffer = ByteBuffer.allocate(2);
shortBuffer.order(ByteOrder.LITTLE_ENDIAN);
//TODO: Disable loop while pause.
while (isRecording) {
chunksCount += recorder.read(data, 0, bufferSize);
if (AudioRecord.ERROR_INVALID_OPERATION != chunksCount) {
long sum = 0;
for (int i = 0; i < bufferSize; i+=2) {
//TODO: find a better way to covert bytes into shorts.
shortBuffer.put(data[i]);
shortBuffer.put(data[i+1]);
sum += Math.abs(shortBuffer.getShort(0));
shortBuffer.clear();
}
// lastVal = (int)(sum/(bufferSize/16));
try {
fos.write(data);
} catch (IOException e) {
Timber.e(e);
// AndroidUtils.runOnUIThread(() -> {
// recorderCallback.onError(new RecordingException());
// stopRecording();
// });
}
}
}
try {
fos.close();
} catch (IOException e) {
Timber.e(e);
}
Timber.i("save header called");
setWaveFileHeader(filePath, channelCount);
}
}
private RandomAccessFile randomAccessFile(File file) {
RandomAccessFile randomAccessFile;
try {
randomAccessFile = new RandomAccessFile(file, "rw");
} catch (FileNotFoundException e) {
Timber.i("Filenot found");
throw new RuntimeException(e);
}
return randomAccessFile;
}
private void setWaveFileHeader(File file, int channels) {
long fileSize = file.length() - 8;
long totalSize = fileSize + 36;
long byteRate = sampleRate * channels * (bpp/8); //2 byte per 1 sample for 1 channel.
try {
final RandomAccessFile wavFile = randomAccessFile(file);
wavFile.seek(0); // to the beginning
wavFile.write(generateHeader(fileSize, totalSize, sampleRate, channels, byteRate));
wavFile.close();
} catch (IOException e) {
Timber.e(e);
}
}
private byte[] generateHeader(
long totalAudioLen, long totalDataLen, long longSampleRate, int channels,
long byteRate) {
Timber.i("generate Header called her");
byte[] header = new byte[44];
header[0] = 'R'; // RIFF/WAVE header
header[1] = 'I';
header[2] = 'F';
header[3] = 'F';
header[4] = (byte) (totalDataLen & 0xff);
header[5] = (byte) ((totalDataLen >> 8) & 0xff);
header[6] = (byte) ((totalDataLen >> 16) & 0xff);
header[7] = (byte) ((totalDataLen >> 24) & 0xff);
header[8] = 'W';
header[9] = 'A';
header[10] = 'V';
header[11] = 'E';
header[12] = 'f'; // 'fmt ' chunk
header[13] = 'm';
header[14] = 't';
header[15] = ' ';
header[16] = 16; //16 for PCM. 4 bytes: size of 'fmt ' chunk
header[17] = 0;
header[18] = 0;
header[19] = 0;
header[20] = 1; // format = 1
header[21] = 0;
header[22] = (byte) channels;
header[23] = 0;
header[24] = (byte) (longSampleRate & 0xff);
header[25] = (byte) ((longSampleRate >> 8) & 0xff);
header[26] = (byte) ((longSampleRate >> 16) & 0xff);
header[27] = (byte) ((longSampleRate >> 24) & 0xff);
header[28] = (byte) (byteRate & 0xff);
header[29] = (byte) ((byteRate >> 8) & 0xff);
header[30] = (byte) ((byteRate >> 16) & 0xff);
header[31] = (byte) ((byteRate >> 24) & 0xff);
header[32] = (byte) (channels * (bpp/8)); // block align
header[33] = 0;
header[34] = bpp; // bits per sample
header[35] = 0;
header[36] = 'd';
header[37] = 'a';
header[38] = 't';
header[39] = 'a';
header[40] = (byte) (totalAudioLen & 0xff);
header[41] = (byte) ((totalAudioLen >> 8) & 0xff);
header[42] = (byte) ((totalAudioLen >> 16) & 0xff);
header[43] = (byte) ((totalAudioLen >> 24) & 0xff);
return header;
}
@SuppressLint("MissingPermission")
public void startRecording(){
try{
int channel = channelCount == 1 ? AudioFormat.CHANNEL_IN_MONO : AudioFormat.CHANNEL_IN_STEREO;
bufferSize = AudioRecord.getMinBufferSize(sampleRate, channel, audioEncoding);
if (bufferSize == AudioRecord.ERROR || bufferSize == AudioRecord.ERROR_BAD_VALUE) {
bufferSize = AudioRecord.getMinBufferSize(sampleRate,
channel,
audioEncoding);
}
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,sampleRate,channel,audioEncoding, bufferSize);
int status = recorder.getState();
if (recorder != null && recorder.getState() == AudioRecord.STATE_INITIALIZED) {
recorder.startRecording();
isRecording = true;
recordingThread = new Thread(this::writeAudioDataToFile, "AudioRecorder Thread");
recordingThread.start();
}
}
catch (Exception e){
Timber.i(e);
}
}
public void stopRecording(){
try{
if(recorder != null) {
isRecording = false;
if (recorder.getState() == AudioRecord.STATE_INITIALIZED) {
try {
recorder.stop();
} catch (IllegalStateException e) {
Timber.e(e, "stopRecording() problems");
}
}
recorder.release();
recordingThread.interrupt();
}
}
catch (Exception e){
Timber.e(e);
}
}
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/RestCallback.java | package com.swaasa.swaasaplatform;
import com.swaasa.swaasaplatform.model.BaseResponse;
public interface RestCallback<T> {
<T extends BaseResponse > void onSuccess(T baseResponse);
void onFailure(BaseResponse baseResponse);
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/apis/APIService.java | package com.swaasa.swaasaplatform.apis;
import com.swaasa.swaasaplatform.model.PredictionResponse;
import com.swaasa.swaasaplatform.model.VerifyCoughResponse;
import java.util.List;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;
public interface APIService {
@Multipart
@POST("verifycough") //cough only
Call<VerifyCoughResponse> verifyCough(@Part MultipartBody.Part file);
@Multipart
@POST("assessment") //cough only
Call<PredictionResponse> predict(
@Part MultipartBody.Part file,
@Part("symptoms") RequestBody symptoms,
@Part("age") RequestBody age,
@Part("gender") RequestBody gender,
@Part("assessmentId") RequestBody assessmentId);
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/model/BaseResponse.java | package com.swaasa.swaasaplatform.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
@Data
public class BaseResponse {
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@SerializedName("status")
@Expose
public String status;
@SerializedName("message")
@Expose
private String message;
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/model/Gender.java | package com.swaasa.swaasaplatform.model;
public enum Gender {
FEMALE(0),
MALE(1);
private final int value;
private Gender(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/model/PredictionResponse.java |
package com.swaasa.swaasaplatform.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;
@Data
public class PredictionResponse extends BaseResponse implements Serializable {
@SerializedName("assessmentId")
@Expose
private String assessmentId;
@SerializedName("data")
@Expose
private Record data;
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/model/Record.java |
package com.swaasa.swaasaplatform.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import lombok.Data;
@Data
public class Record implements Serializable {
@SerializedName("status")
@Expose
private String status;
@SerializedName("risk")
@Expose
private String risk;
@SerializedName("lung_health_index")
@Expose
private int lungHealthIndex;
@SerializedName("cough_pattern")
@Expose
private String coughPattern;
@SerializedName("severity")
@Expose
private String severity;
@SerializedName("dry_cough_count")
@Expose
private String dryCoughCount;
@SerializedName("wet_cough_count")
@Expose
private String wetCoughCount;
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/model/Symptoms.java | package com.swaasa.swaasaplatform.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Data;
@Data
public class Symptoms implements Serializable {
@SerializedName("frequent_cough")
@Expose
public int frequentCough;
@SerializedName("sputum")
@Expose
public int sputum;
@SerializedName("cough_at_night")
@Expose
public int coughAtNight;
@SerializedName("wheezing")
@Expose
public int wheezing;
@SerializedName("pain_in_chest")
@Expose
public int painInChest;
@SerializedName("shortness_of_breath")
@Expose
public int shortnessOfBreath;
}
|
0 | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform | java-sources/ai/swaasa/sdk/android-sdk/1.1/com/swaasa/swaasaplatform/model/VerifyCoughResponse.java | package com.swaasa.swaasaplatform.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import lombok.Getter;
import lombok.ToString;
@ToString
@Getter
public class VerifyCoughResponse extends BaseResponse implements Serializable{
@SerializedName("data")
@Expose
public Data data;
@ToString
public class Data implements Serializable {
@SerializedName("isValidCough")
@Expose
public boolean isValidCough;
@SerializedName("message")
@Expose
public String message;
}
}
|
0 | java-sources/ai/swim/swim-api | java-sources/ai/swim/swim-api/3.10.0/module-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Agent programming interface.
*/
module swim.api {
requires transitive swim.util;
requires transitive swim.codec;
requires transitive swim.structure;
requires transitive swim.math;
requires transitive swim.spatial;
requires transitive swim.observable;
requires transitive swim.streamlet;
requires transitive swim.dataflow;
requires transitive swim.http;
requires transitive swim.ws;
requires transitive swim.mqtt;
requires transitive swim.warp;
requires transitive swim.concurrent;
requires transitive swim.io;
exports swim.api;
exports swim.api.agent;
exports swim.api.auth;
exports swim.api.client;
exports swim.api.data;
exports swim.api.downlink;
exports swim.api.function;
exports swim.api.http;
exports swim.api.http.function;
exports swim.api.lane;
exports swim.api.lane.function;
exports swim.api.plane;
exports swim.api.policy;
exports swim.api.ref;
exports swim.api.service;
exports swim.api.space;
exports swim.api.store;
exports swim.api.warp;
exports swim.api.warp.function;
exports swim.api.ws;
exports swim.api.ws.function;
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/Downlink.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
import swim.api.function.DidClose;
import swim.api.function.DidConnect;
import swim.api.function.DidDisconnect;
import swim.api.function.DidFail;
public interface Downlink extends Link {
@Override
Downlink observe(Object observer);
@Override
Downlink unobserve(Object observer);
Downlink didConnect(DidConnect didConnect);
Downlink didDisconnect(DidDisconnect didDisconnect);
Downlink didClose(DidClose didClose);
Downlink didFail(DidFail didFail);
Downlink open();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/DownlinkException.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
public class DownlinkException extends RuntimeException {
private static final long serialVersionUID = 1L;
public DownlinkException(String message, Throwable cause) {
super(message, cause);
}
public DownlinkException(String message) {
super(message);
}
public DownlinkException(Throwable cause) {
super(cause);
}
public DownlinkException() {
super();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/Lane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
import swim.observable.Observable;
import swim.uri.Uri;
import swim.util.Log;
public interface Lane extends Observable<Object>, Log {
Uri hostUri();
Uri nodeUri();
Uri laneUri();
void close();
@Override
Lane observe(Object observer);
@Override
Lane unobserve(Object observer);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/LaneException.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
public class LaneException extends RuntimeException {
private static final long serialVersionUID = 1L;
public LaneException(String message, Throwable cause) {
super(message, cause);
}
public LaneException(String message) {
super(message);
}
public LaneException(Throwable cause) {
super(cause);
}
public LaneException() {
super();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/Link.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
import java.net.InetSocketAddress;
import java.security.Principal;
import java.security.cert.Certificate;
import java.util.Collection;
import swim.api.auth.Identity;
import swim.observable.Observable;
import swim.uri.Uri;
import swim.util.Log;
public interface Link extends Observable<Object>, Log {
Uri hostUri();
Uri nodeUri();
Uri laneUri();
boolean isConnected();
boolean isRemote();
boolean isSecure();
String securityProtocol();
String cipherSuite();
InetSocketAddress localAddress();
Identity localIdentity();
Principal localPrincipal();
Collection<Certificate> localCertificates();
InetSocketAddress remoteAddress();
Identity remoteIdentity();
Principal remotePrincipal();
Collection<Certificate> remoteCertificates();
void close();
@Override
Link observe(Object observer);
@Override
Link unobserve(Object observer);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/LinkException.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
public class LinkException extends RuntimeException {
private static final long serialVersionUID = 1L;
public LinkException(String message, Throwable cause) {
super(message, cause);
}
public LinkException(String message) {
super(message);
}
public LinkException(Throwable cause) {
super(cause);
}
public LinkException() {
super();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/SwimAgent.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface SwimAgent {
String value() default "";
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/SwimContext.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
import swim.api.agent.AgentContext;
import swim.api.plane.PlaneContext;
import swim.api.service.ServiceContext;
/**
* Thread-local context variables.
*/
public final class SwimContext {
private SwimContext() {
// nop
}
private static final ThreadLocal<ServiceContext> SERVICE_CONTEXT = new ThreadLocal<>();
private static final ThreadLocal<PlaneContext> PLANE_CONTEXT = new ThreadLocal<>();
private static final ThreadLocal<AgentContext> AGENT_CONTEXT = new ThreadLocal<>();
private static final ThreadLocal<Lane> LANE = new ThreadLocal<>();
private static final ThreadLocal<Link> LINK = new ThreadLocal<>();
public static ServiceContext getServiceContext() {
return SERVICE_CONTEXT.get();
}
public static void setServiceContext(ServiceContext serviceContext) {
SERVICE_CONTEXT.set(serviceContext);
}
public static PlaneContext getPlaneContext() {
return PLANE_CONTEXT.get();
}
public static void setPlaneContext(PlaneContext planeContext) {
PLANE_CONTEXT.set(planeContext);
}
public static AgentContext getAgentContext() {
return AGENT_CONTEXT.get();
}
public static void setAgentContext(AgentContext agentContext) {
AGENT_CONTEXT.set(agentContext);
}
public static Lane getLane() {
return LANE.get();
}
public static void setLane(Lane lane) {
LANE.set(lane);
}
public static Link getLink() {
return LINK.get();
}
public static void setLink(Link link) {
LINK.set(link);
}
public static void clear() {
SERVICE_CONTEXT.remove();
PLANE_CONTEXT.remove();
AGENT_CONTEXT.remove();
LANE.remove();
LINK.remove();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/SwimLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface SwimLane {
String value();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/SwimResident.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface SwimResident {
boolean value() default true;
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/SwimRoute.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface SwimRoute {
String value();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/SwimTransient.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Target({ElementType.FIELD, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface SwimTransient {
boolean value() default true;
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/Uplink.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
public interface Uplink extends Link {
@Override
Uplink observe(Object observer);
@Override
Uplink unobserve(Object observer);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/UplinkException.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api;
public class UplinkException extends LinkException {
private static final long serialVersionUID = 1L;
public UplinkException(String message, Throwable cause) {
super(message, cause);
}
public UplinkException(String message) {
super(message);
}
public UplinkException(Throwable cause) {
super(cause);
}
public UplinkException() {
super();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim | java-sources/ai/swim/swim-api/3.10.0/swim/api/package-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Agent programming interface.
*/
package swim.api;
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/AbstractAgent.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.agent;
import java.net.InetSocketAddress;
import java.security.Principal;
import java.security.cert.Certificate;
import java.util.Collection;
import swim.api.Lane;
import swim.api.Link;
import swim.api.SwimContext;
import swim.api.auth.Identity;
import swim.api.data.ListData;
import swim.api.data.MapData;
import swim.api.data.SpatialData;
import swim.api.data.ValueData;
import swim.api.downlink.EventDownlink;
import swim.api.downlink.ListDownlink;
import swim.api.downlink.MapDownlink;
import swim.api.downlink.ValueDownlink;
import swim.api.http.HttpDownlink;
import swim.api.http.HttpLane;
import swim.api.lane.CommandLane;
import swim.api.lane.DemandLane;
import swim.api.lane.DemandMapLane;
import swim.api.lane.JoinMapLane;
import swim.api.lane.JoinValueLane;
import swim.api.lane.LaneFactory;
import swim.api.lane.ListLane;
import swim.api.lane.MapLane;
import swim.api.lane.SpatialLane;
import swim.api.lane.SupplyLane;
import swim.api.lane.ValueLane;
import swim.api.ref.HostRef;
import swim.api.ref.LaneRef;
import swim.api.ref.NodeRef;
import swim.api.ref.SwimRef;
import swim.api.store.Store;
import swim.api.ws.WsDownlink;
import swim.api.ws.WsLane;
import swim.collections.FingerTrieSeq;
import swim.concurrent.Schedule;
import swim.concurrent.Stage;
import swim.concurrent.TimerFunction;
import swim.concurrent.TimerRef;
import swim.math.R2Shape;
import swim.math.Z2Form;
import swim.structure.Value;
import swim.uri.Uri;
import swim.util.Log;
/**
* Abstract base class for <em>all</em> {@link Agent Agents}. This class
* provides skeletal {@code Agent} lifecycle callback implementations,
* contextual {@code Lane} and {@code Store} creation mechanisms, URI-based
* addressability, logging, and scheduling, primarily via delegation to its
* internal, immutable {@link AgentContext}.
*/
public class AbstractAgent implements Agent, SwimRef, LaneFactory, Schedule, Store, Log {
/**
* Internal, immutable context that provides contextual {@code Lane} and
* {@code Store} creation mechanisms, URI-based addressability, logging, and
* scheduling.
*/
protected final AgentContext context;
/**
* Creates an {@code AbstractAgent} instance managed by {@code context}.
*/
public AbstractAgent(AgentContext context) {
this.context = context;
}
/**
* Creates an {@code AbstractAgent} instance managed by {@link
* SwimContext#getAgentContext()}.
*/
public AbstractAgent() {
this(SwimContext.getAgentContext());
}
@Override
public AgentContext agentContext() {
return this.context;
}
@Override
public void willOpen() {
// hook
}
@Override
public void didOpen() {
// hook
}
@Override
public void willLoad() {
// hook
}
@Override
public void didLoad() {
// hook
}
@Override
public void willStart() {
// hook
}
@Override
public void didStart() {
// hook
}
@Override
public void willStop() {
// hook
}
@Override
public void didStop() {
// hook
}
@Override
public void willUnload() {
// hook
}
@Override
public void didUnload() {
// hook
}
@Override
public void willClose() {
// hook
}
@Override
public void didClose() {
// hook
}
@Override
public void didFail(Throwable error) {
error.printStackTrace();
}
/**
* This {@code Agent}'s {@code hostUri}.
*/
public final Uri hostUri() {
return this.context.hostUri();
}
/**
* This {@code Agent}'s {@code nodeUri}.
*/
public final Uri nodeUri() {
return this.context.nodeUri();
}
/**
* A {@link swim.structure.Record} that maps every dynamic property in
* {@link #nodeUri()}, as defined by {@link AgentRoute#pattern()}, to its
* value. An empty result indicates that {@code nodeUri} contains no
* dynamic components.
*/
public final Value props() {
return this.context.props();
}
/**
* Returns the value of {@code key} in {@link #props()}.
*/
public final Value getProp(Value key) {
return this.context.getProp(key);
}
/**
* Returns the value of {@code name} in {@link #props()}.
*/
public final Value getProp(String name) {
return this.context.getProp(name);
}
/**
* The {@link Schedule} that this {@code Agent} is bound to.
*/
public final Schedule schedule() {
return this.context.schedule();
}
/**
* The {@link Stage} that this {@code Agent} is bound to.
*/
public final Stage stage() {
return this.context.stage();
}
/**
* Returns the currently executing lane, or null if not currently executing
* a lane or link callback.
*/
public final Lane lane() {
return this.context.lane();
}
/**
* Returns the currently executing link, or null if not currently executing
* a link callback.
*/
public final Link link() {
return this.context.link();
}
public final Lane getLane(Uri laneUri) {
return this.context.getLane(laneUri);
}
public final Lane openLane(Uri laneUri, Lane lane) {
return this.context.openLane(laneUri, lane);
}
public FingerTrieSeq<Agent> agents() {
return this.context.agents();
}
public Agent getAgent(Value props) {
return this.context.getAgent(props);
}
public Agent getAgent(String name) {
return this.context.getAgent(name);
}
public <A extends Agent> A getAgent(Class<A> agentClass) {
return this.context.getAgent(agentClass);
}
public <A extends Agent> A addAgent(Value props, AgentFactory<A> agentFactory) {
return this.context.addAgent(props, agentFactory);
}
public <A extends Agent> A addAgent(String name, AgentFactory<A> agentFactory) {
return this.context.addAgent(name, agentFactory);
}
public <A extends Agent> A addAgent(Value props, Class<A> agentClass) {
return this.context.addAgent(props, agentClass);
}
public <A extends Agent> A addAgent(String name, Class<A> agentClass) {
return this.context.addAgent(name, agentClass);
}
public void removeAgent(Value props) {
this.context.removeAgent(props);
}
public void removeAgent(String name) {
this.context.removeAgent(name);
}
/**
* Returns true if the currently executing link is secure, or false if the
* currently executing link is not secure, or if not currently executing a
* link callback.
*/
public boolean isSecure() {
final Link link = link();
return link != null && link.isSecure();
}
/**
* Returns the security protocol used by the currently executing link, or
* null if the currently executing link is not secure, or if not currently
* executing a link callback.
*/
public String securityProtocol() {
final Link link = link();
if (link != null) {
return link.securityProtocol();
} else {
return null;
}
}
/**
* Returns the cryptographic cipher suite used by the currently executing
* link, or null if the currently executing link is not secure, or if not
* currently executing a link callback.
*/
public String cipherSuite() {
final Link link = link();
if (link != null) {
return link.cipherSuite();
} else {
return null;
}
}
/**
* Returns the local internet address of the currently executing link, or
* null if not currently executing a link callback.
*/
public InetSocketAddress localAddress() {
final Link link = link();
if (link != null) {
return link.localAddress();
} else {
return null;
}
}
/**
* Returns the local user identity of the currently executing link, or null
* if the currently executing link has no local user identity, or if not
* currently executing a link callback.
*/
public Identity localIdentity() {
final Link link = link();
if (link != null) {
return link.localIdentity();
} else {
return null;
}
}
/**
* Returns the principal used to identify the local end of the currently
* executing link, or null if the currently executing link has no local
* principal, or if not currently executing a link callback.
*/
public Principal localPrincipal() {
final Link link = link();
if (link != null) {
return link.localPrincipal();
} else {
return null;
}
}
/**
* Returns the certificates used to authenticate the local end of the
* currently executing link; returns an empty collection if the currently
* executing link has no local certificates, or if not currently executing a
* link callback.
*/
public Collection<Certificate> localCertificates() {
final Link link = link();
if (link != null) {
return link.localCertificates();
} else {
return FingerTrieSeq.empty();
}
}
/**
* Returns the remote internet address of the currently executing link, or
* null if not currently executing a link callback.
*/
public InetSocketAddress remoteAddress() {
final Link link = link();
if (link != null) {
return link.remoteAddress();
} else {
return null;
}
}
/**
* Returns the remote user identity of the currently executing link, or null
* if the currently executing link has no remote user identity, or if not
* currently executing a link callback.
*/
public Identity remoteIdentity() {
final Link link = link();
if (link != null) {
return link.remoteIdentity();
} else {
return null;
}
}
/**
* Returns the principal used to identify the remote end of the currently
* executing link, or null if the currently executing link has no remote
* principal, or if not currently executing a link callback.
*/
public Principal remotePrincipal() {
final Link link = link();
if (link != null) {
return link.remotePrincipal();
} else {
return null;
}
}
/**
* Returns the certificates used to authenticate the remote end of the
* currently executing link; returns an empty collection if the currently
* executing link has no remote certificates, or if not currently executing a
* link callback.
*/
public Collection<Certificate> remoteCertificates() {
final Link link = link();
if (link != null) {
return link.remoteCertificates();
} else {
return FingerTrieSeq.empty();
}
}
@Override
public final <V> CommandLane<V> commandLane() {
return this.context.commandLane();
}
@Override
public final <V> DemandLane<V> demandLane() {
return this.context.demandLane();
}
@Override
public final <K, V> DemandMapLane<K, V> demandMapLane() {
return this.context.demandMapLane();
}
@Override
public final <V> HttpLane<V> httpLane() {
return this.context.httpLane();
}
@Override
public final <L, K, V> JoinMapLane<L, K, V> joinMapLane() {
return this.context.joinMapLane();
}
@Override
public final <K, V> JoinValueLane<K, V> joinValueLane() {
return this.context.joinValueLane();
}
@Override
public final <V> ListLane<V> listLane() {
return this.context.listLane();
}
@Override
public final <K, V> MapLane<K, V> mapLane() {
return this.context.mapLane();
}
@Override
public final <K, S, V> SpatialLane<K, S, V> spatialLane(Z2Form<S> shapeForm) {
return this.context.spatialLane(shapeForm);
}
@Override
public final <K, V> SpatialLane<K, R2Shape, V> geospatialLane() {
return this.context.geospatialLane();
}
@Override
public final <V> SupplyLane<V> supplyLane() {
return this.context.supplyLane();
}
@Override
public final <V> ValueLane<V> valueLane() {
return this.context.valueLane();
}
@Override
public final <I, O> WsLane<I, O> wsLane() {
return this.context.wsLane();
}
@Override
public final ListData<Value> listData(Value name) {
return this.context.listData(name);
}
@Override
public final ListData<Value> listData(String name) {
return this.context.listData(name);
}
@Override
public final MapData<Value, Value> mapData(Value name) {
return this.context.mapData(name);
}
@Override
public final MapData<Value, Value> mapData(String name) {
return this.context.mapData(name);
}
@Override
public final <S> SpatialData<Value, S, Value> spatialData(Value name, Z2Form<S> shapeForm) {
return this.context.spatialData(name, shapeForm);
}
@Override
public final <S> SpatialData<Value, S, Value> spatialData(String name, Z2Form<S> shapeForm) {
return this.context.spatialData(name, shapeForm);
}
@Override
public final SpatialData<Value, R2Shape, Value> geospatialData(Value name) {
return this.context.geospatialData(name);
}
@Override
public final SpatialData<Value, R2Shape, Value> geospatialData(String name) {
return this.context.geospatialData(name);
}
@Override
public final ValueData<Value> valueData(Value name) {
return this.context.valueData(name);
}
@Override
public final ValueData<Value> valueData(String name) {
return this.context.valueData(name);
}
@Override
public final EventDownlink<Value> downlink() {
return this.context.downlink();
}
@Override
public final ListDownlink<Value> downlinkList() {
return this.context.downlinkList();
}
@Override
public final MapDownlink<Value, Value> downlinkMap() {
return this.context.downlinkMap();
}
@Override
public final ValueDownlink<Value> downlinkValue() {
return this.context.downlinkValue();
}
@Override
public final <V> HttpDownlink<V> downlinkHttp() {
return this.context.downlinkHttp();
}
@Override
public final <I, O> WsDownlink<I, O> downlinkWs() {
return this.context.downlinkWs();
}
@Override
public final HostRef hostRef(Uri hostUri) {
return this.context.hostRef(hostUri);
}
@Override
public final HostRef hostRef(String hostUri) {
return this.context.hostRef(hostUri);
}
@Override
public final NodeRef nodeRef(Uri hostUri, Uri nodeUri) {
return this.context.nodeRef(hostUri, nodeUri);
}
@Override
public final NodeRef nodeRef(String hostUri, String nodeUri) {
return this.context.nodeRef(hostUri, nodeUri);
}
@Override
public final NodeRef nodeRef(Uri nodeUri) {
return this.context.nodeRef(nodeUri);
}
@Override
public final NodeRef nodeRef(String nodeUri) {
return this.context.nodeRef(nodeUri);
}
@Override
public final LaneRef laneRef(Uri hostUri, Uri nodeUri, Uri laneUri) {
return this.context.laneRef(hostUri, nodeUri, laneUri);
}
@Override
public final LaneRef laneRef(String hostUri, String nodeUri, String laneUri) {
return this.context.laneRef(hostUri, nodeUri, laneUri);
}
@Override
public final LaneRef laneRef(Uri nodeUri, Uri laneUri) {
return this.context.laneRef(nodeUri, laneUri);
}
@Override
public final LaneRef laneRef(String nodeUri, String laneUri) {
return this.context.laneRef(nodeUri, laneUri);
}
@Override
public final void command(Uri hostUri, Uri nodeUri, Uri laneUri, float prio, Value body) {
this.context.command(hostUri, nodeUri, laneUri, prio, body);
}
@Override
public final void command(String hostUri, String nodeUri, String laneUri, float prio, Value body) {
this.context.command(hostUri, nodeUri, laneUri, prio, body);
}
@Override
public final void command(Uri hostUri, Uri nodeUri, Uri laneUri, Value body) {
this.context.command(hostUri, nodeUri, laneUri, body);
}
@Override
public final void command(String hostUri, String nodeUri, String laneUri, Value body) {
this.context.command(hostUri, nodeUri, laneUri, body);
}
@Override
public final void command(Uri nodeUri, Uri laneUri, float prio, Value body) {
this.context.command(nodeUri, laneUri, prio, body);
}
@Override
public final void command(String nodeUri, String laneUri, float prio, Value body) {
this.context.command(nodeUri, laneUri, prio, body);
}
@Override
public final void command(Uri nodeUri, Uri laneUri, Value body) {
this.context.command(nodeUri, laneUri, body);
}
@Override
public final void command(String nodeUri, String laneUri, Value body) {
this.context.command(nodeUri, laneUri, body);
}
@Override
public void trace(Object message) {
final Link link = link();
if (link != null) {
link.trace(message);
} else {
this.context.trace(message);
}
}
@Override
public void debug(Object message) {
final Link link = link();
if (link != null) {
link.debug(message);
} else {
this.context.debug(message);
}
}
@Override
public void info(Object message) {
final Link link = link();
if (link != null) {
link.info(message);
} else {
this.context.info(message);
}
}
@Override
public void warn(Object message) {
final Link link = link();
if (link != null) {
link.warn(message);
} else {
this.context.warn(message);
}
}
@Override
public void error(Object message) {
final Link link = link();
if (link != null) {
link.error(message);
} else {
this.context.error(message);
}
}
@Override
public final TimerRef timer(TimerFunction timer) {
return schedule().timer(timer);
}
@Override
public final TimerRef setTimer(long millis, TimerFunction timer) {
return schedule().setTimer(millis, timer);
}
@Override
public void close() {
this.context.close();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/AbstractAgentRoute.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.agent;
import swim.collections.HashTrieMap;
import swim.structure.Record;
import swim.structure.Value;
import swim.uri.Uri;
import swim.uri.UriPattern;
public abstract class AbstractAgentRoute<A extends Agent> implements AgentRoute<A> {
protected AgentRouteContext context;
@Override
public AgentRouteContext agentRouteContext() {
return this.context;
}
@Override
public void setAgentRouteContext(AgentRouteContext context) {
this.context = context;
}
@Override
public String routeName() {
final AgentRouteContext context = this.context;
return context != null ? context.routeName() : null;
}
@Override
public UriPattern pattern() {
final AgentRouteContext context = this.context;
return context != null ? context.pattern() : null;
}
@Override
public abstract A createAgent(AgentContext context);
@Override
public Value props(Uri nodeUri) {
final Record props = Record.create();
final UriPattern pattern = pattern();
if (pattern != null) {
final HashTrieMap<String, String> params = pattern.unapply(nodeUri);
for (HashTrieMap.Entry<String, String> param : params) {
props.slot(param.getKey(), param.getValue());
}
}
return props;
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/Agent.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.agent;
public interface Agent {
/**
* Returns the {@link AgentContext} used to manage this {@code Agent}.
*/
AgentContext agentContext();
/**
* Lifecycle callback invoked immediately before this {@code Agent} opens.
*
* //@see swim.runtime.TierBinding#open
*/
void willOpen();
/**
* Lifecycle callback invoked immediately after this {@code Agent} opens, i.e.
* before it loads.
*
* //@see swim.runtime.TierBinding#open
* //@see swim.runtime.TierBinding#load
*/
void didOpen();
/**
* Lifecycle callback invoked immediately before this {@code Agent} loads.
*
* //@see swim.runtime.TierBinding#load
*/
void willLoad();
/**
* Lifecycle callback invoked immediately after this {@code Agent} loads, i.e.
* before it starts.
*
* //@see swim.runtime.TierBinding#load
* //@see swim.runtime.TierBinding#start
*/
void didLoad();
/**
* Lifecycle callback invoked immediately before this {@code Agent} starts.
*
* //@see swim.runtime.TierBinding#start
*/
void willStart();
/**
* Lifecycle callback invoked immediately after this {@code Agent} starts.
*
* //@see swim.runtime.TierBinding#start
*/
void didStart();
/**
* Lifecycle callback invoked immediately before this {@code Agent} stops.
*
* //@see swim.runtime.TierBinding#stop
*/
void willStop();
/**
* Lifecycle callback invoked immediately after this {@code Agent} stops, i.e.
* before it unloads.
*
* //@see swim.runtime.TierBinding#stop
* //@see swim.runtime.TierBinding#unload
*/
void didStop();
/**
* Lifecycle callback invoked immediately before this {@code Agent} unloads.
*
* //@see swim.runtime.TierBinding#unload
*/
void willUnload();
/**
* Lifecycle callback invoked immediately after this {@code Agent} unloads,
* i.e. before it closes.
*
* //@see swim.runtime.TierBinding.unload
* //@see swim.runtime.TierBinding.close
*/
void didUnload();
/**
* Lifecycle callback invoked immediately before this {@code Agent} closes.
*
* //@see swim.runtime.TierBinding.close
*/
void willClose();
/**
* Lifecycle callback invoked immediately after this {@code Agent} closes.
*
* //@see swim.runtime.TierBinding.close
*/
void didClose();
/**
* Lifecycle callback invoked immediately after this {@code Agent} throws
* {@code error}.
*/
void didFail(Throwable error);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/AgentContext.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.agent;
import swim.api.Lane;
import swim.api.Link;
import swim.api.lane.LaneFactory;
import swim.api.ref.SwimRef;
import swim.api.store.Store;
import swim.collections.FingerTrieSeq;
import swim.concurrent.Schedule;
import swim.concurrent.Stage;
import swim.structure.Value;
import swim.uri.Uri;
import swim.util.Log;
/**
* Internal context that enables URI-based addressability, contextual {@code
* Lane} and {@code Store} creation mechanisms, logging, and scheduling to some
* {@link Agent}.
*/
public interface AgentContext extends SwimRef, LaneFactory, Store, Log {
/**
* The {@code hostUri} of the {@code Agent} managed by this {@code
* AgentContext}.
*/
Uri hostUri();
/**
* The {@code nodeUri} of the {@code Agent} managed by this {@code
* AgentContext}.
*/
Uri nodeUri();
/**
* A {@link swim.structure.Record} that maps every dynamic property in
* {@link #nodeUri()}, as defined by {@link AgentRoute#pattern()}, to its
* value. An empty result indicates that {@code nodeUri} contains no
* dynamic components.
*/
Value props();
/**
* Returns the value of {@code key} in {@link #props()}.
*/
Value getProp(Value key);
/**
* Returns the value of {@code name} in {@link #props()}.
*/
Value getProp(String name);
/**
* The {@link Schedule} that this {@code AgentContext} is bound to.
*/
Schedule schedule();
/**
* The {@link Stage} that this {@code AgentContext} is bound to.
*/
Stage stage();
/**
* Returns the currently executing lane, or null if not currently executing
* a lane or link callback.
*/
Lane lane();
/**
* Returns the currently executing link, or null if not currently executing
* a link callback.
*/
Link link();
/**
* Returns the {@code Lane} belonging to the {@code Agent} managed by this
* {@code AgentContext} that is addressable by {@code laneUri}, or {@code
* null} if no such {@code Lane} exists.
*/
Lane getLane(Uri laneUri);
/**
* Registers {@code lane} with {@code laneUri} and returns {@code lane}.
*/
Lane openLane(Uri laneUri, Lane lane);
FingerTrieSeq<Agent> agents();
Agent getAgent(Value props);
Agent getAgent(String name);
<A extends Agent> A getAgent(Class<? extends A> agentClass);
<A extends Agent> A addAgent(Value props, AgentFactory<A> agentFactory);
<A extends Agent> A addAgent(String name, AgentFactory<A> agentFactory);
<A extends Agent> A addAgent(Value props, Class<? extends A> agentClass);
<A extends Agent> A addAgent(String name, Class<? extends A> agentClass);
void removeAgent(Value props);
void removeAgent(String name);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/AgentDef.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.agent;
import swim.structure.Value;
public interface AgentDef {
String agentName();
Value props();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/AgentException.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.agent;
public class AgentException extends RuntimeException {
private static final long serialVersionUID = 1L;
public AgentException(String message, Throwable cause) {
super(message, cause);
}
public AgentException(String message) {
super(message);
}
public AgentException(Throwable cause) {
super(cause);
}
public AgentException() {
super();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/AgentFactory.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.agent;
import swim.structure.Value;
import swim.uri.Uri;
/**
* For some class {@code A extends Agent}, factory to create instances of
* {@code A}.
*/
public interface AgentFactory<A extends Agent> {
/**
* Creates an instance of {@code A} with internal context {@code context}.
*/
A createAgent(AgentContext context);
Value props(Uri nodeUri);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/AgentRoute.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.agent;
import swim.uri.UriPattern;
/**
* Factory for {@link Agent agents} that are lazily instantiated when a node
* URI route pattern is accessed.
*/
public interface AgentRoute<A extends Agent> extends AgentFactory<A> {
/**
* The internal context used to provide concrete implementations to most
* {@code AgentRoute} methods.
*/
AgentRouteContext agentRouteContext();
/**
* Updates the internal context used to provide concrete implementations to
* most {@code AgentRoute} methods.
*/
void setAgentRouteContext(AgentRouteContext context);
/**
* Returns a plane-unique identifier for this agent route.
*/
String routeName();
/**
* The {@code UriPattern} that every {@code nodeUri} corresponding to an
* instance of {@code A} must match.
*/
UriPattern pattern();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/AgentRouteContext.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.agent;
import swim.uri.UriPattern;
/**
* Internal context that provides concrete implementations for most {@link
* AgentRoute} methods.
*/
public interface AgentRouteContext {
/**
* @see AgentRoute#routeName()
*/
String routeName();
/**
* @see AgentRoute#pattern()
*/
UriPattern pattern();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/agent/package-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Agent runtime interface.
*/
package swim.api.agent;
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/auth/AbstractAuthenticator.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.auth;
import java.net.InetSocketAddress;
import swim.api.policy.PolicyDirective;
import swim.concurrent.Schedule;
import swim.concurrent.Stage;
import swim.io.IpInterface;
import swim.io.IpService;
import swim.io.IpServiceRef;
import swim.io.IpSettings;
import swim.io.IpSocket;
import swim.io.IpSocketRef;
import swim.util.Log;
public abstract class AbstractAuthenticator implements Authenticator, IpInterface, Log {
protected AuthenticatorContext context;
@Override
public AuthenticatorContext authenticatorContext() {
return this.context;
}
@Override
public void setAuthenticatorContext(AuthenticatorContext context) {
this.context = context;
}
public Schedule schedule() {
return this.context.schedule();
}
public Stage stage() {
return this.context.stage();
}
@Override
public IpSettings ipSettings() {
return this.context.ipSettings();
}
@Override
public IpServiceRef bindTcp(InetSocketAddress localAddress, IpService service, IpSettings ipSettings) {
return this.context.bindTcp(localAddress, service, ipSettings);
}
@Override
public IpServiceRef bindTls(InetSocketAddress localAddress, IpService service, IpSettings ipSettings) {
return this.context.bindTls(localAddress, service, ipSettings);
}
@Override
public IpSocketRef connectTcp(InetSocketAddress remoteAddress, IpSocket socket, IpSettings ipSettings) {
return this.context.connectTcp(remoteAddress, socket, ipSettings);
}
@Override
public IpSocketRef connectTls(InetSocketAddress remoteAddress, IpSocket socket, IpSettings ipSettings) {
return this.context.connectTls(remoteAddress, socket, ipSettings);
}
@Override
public abstract PolicyDirective<Identity> authenticate(Credentials credentials);
@Override
public void trace(Object message) {
this.context.trace(message);
}
@Override
public void debug(Object message) {
this.context.debug(message);
}
@Override
public void info(Object message) {
this.context.info(message);
}
@Override
public void warn(Object message) {
this.context.warn(message);
}
@Override
public void error(Object message) {
this.context.error(message);
}
@Override
public void willStart() {
// hook
}
@Override
public void didStart() {
// hook
}
@Override
public void willStop() {
// hook
}
@Override
public void didStop() {
// hook
}
@Override
public void didFail(Throwable error) {
// hook
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/auth/Authenticator.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.auth;
import swim.api.policy.PolicyDirective;
public interface Authenticator {
AuthenticatorContext authenticatorContext();
void setAuthenticatorContext(AuthenticatorContext context);
PolicyDirective<Identity> authenticate(Credentials credentials);
void willStart();
void didStart();
void willStop();
void didStop();
void didFail(Throwable error);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/auth/AuthenticatorContext.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.auth;
import swim.concurrent.Schedule;
import swim.concurrent.Stage;
import swim.io.IpInterface;
import swim.util.Log;
public interface AuthenticatorContext extends IpInterface, Log {
Schedule schedule();
Stage stage();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/auth/AuthenticatorDef.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.auth;
public interface AuthenticatorDef {
String authenticatorName();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/auth/AuthenticatorException.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.auth;
public class AuthenticatorException extends RuntimeException {
private static final long serialVersionUID = 1L;
public AuthenticatorException(String message, Throwable cause) {
super(message, cause);
}
public AuthenticatorException(String message) {
super(message);
}
public AuthenticatorException(Throwable cause) {
super(cause);
}
public AuthenticatorException() {
super();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/auth/Credentials.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.auth;
import swim.structure.Value;
import swim.uri.Uri;
public interface Credentials {
Uri requestUri();
Uri fromUri();
Value claims();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/auth/Identity.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.auth;
import swim.api.store.Store;
import swim.structure.Value;
import swim.uri.Uri;
public interface Identity {
boolean isAuthenticated();
Uri requestUri();
Uri fromUri();
Value subject();
Store data();
Store session();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/auth/package-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Authentication runtime interface.
*/
package swim.api.auth;
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/client/Client.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.client;
import swim.api.ref.SwimRef;
public interface Client extends SwimRef {
//Credentials getCredentials(Uri hostUri);
void start();
void stop();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/client/ClientException.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.client;
public class ClientException extends RuntimeException {
private static final long serialVersionUID = 1L;
public ClientException(String message, Throwable cause) {
super(message, cause);
}
public ClientException(String message) {
super(message);
}
public ClientException(Throwable cause) {
super(cause);
}
public ClientException() {
super();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/client/package-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Client runtime interface.
*/
package swim.api.client;
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/data/ListData.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.data;
import swim.structure.Form;
import swim.structure.Value;
import swim.util.KeyedList;
public interface ListData<V> extends KeyedList<V> {
Value name();
Form<V> valueForm();
<V2> ListData<V2> valueForm(Form<V2> valueForm);
<V2> ListData<V2> valueClass(Class<V2> valueClass);
boolean isResident();
ListData<V> isResident(boolean isResident);
boolean isTransient();
ListData<V> isTransient(boolean isTransient);
void drop(int lower);
void take(int keep);
KeyedList<V> snapshot();
void close();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/data/MapData.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.data;
import swim.structure.Form;
import swim.structure.Value;
import swim.util.OrderedMap;
public interface MapData<K, V> extends OrderedMap<K, V> {
Value name();
Form<K> keyForm();
<K2> MapData<K2, V> keyForm(Form<K2> keyForm);
<K2> MapData<K2, V> keyClass(Class<K2> keyClass);
Form<V> valueForm();
<V2> MapData<K, V2> valueForm(Form<V2> valueForm);
<V2> MapData<K, V2> valueClass(Class<V2> valueClass);
boolean isResident();
MapData<K, V> isResident(boolean isResident);
boolean isTransient();
MapData<K, V> isTransient(boolean isTransient);
void drop(int lower);
void take(int keep);
OrderedMap<K, V> snapshot();
void close();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/data/SpatialData.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.data;
import swim.math.Z2Form;
import swim.spatial.SpatialMap;
import swim.structure.Form;
import swim.structure.Value;
public interface SpatialData<K, S, V> extends SpatialMap<K, S, V> {
Value name();
Form<K> keyForm();
<K2> SpatialData<K2, S, V> keyForm(Form<K2> keyForm);
<K2> SpatialData<K2, S, V> keyClass(Class<K2> keyClass);
Z2Form<S> shapeForm();
Form<V> valueForm();
<V2> SpatialData<K, S, V2> valueForm(Form<V2> valueForm);
<V2> SpatialData<K, S, V2> valueClass(Class<V2> valueClass);
boolean isResident();
SpatialData<K, S, V> isResident(boolean isResident);
boolean isTransient();
SpatialData<K, S, V> isTransient(boolean isTransient);
SpatialMap<K, S, V> snapshot();
void close();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/data/ValueData.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.data;
import swim.structure.Form;
import swim.structure.Value;
public interface ValueData<V> {
Value name();
Form<V> valueForm();
<V2> ValueData<V2> valueForm(Form<V2> valueForm);
<V2> ValueData<V2> valueClass(Class<V2> valueClass);
boolean isResident();
ValueData<V> isResident(boolean isResident);
boolean isTransient();
ValueData<V> isTransient(boolean isTransient);
V get();
V set(V newValue);
void close();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/data/package-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Data runtime interface.
*/
package swim.api.data;
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/DownlinkFactory.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import swim.api.http.HttpDownlink;
import swim.api.ws.WsDownlink;
import swim.structure.Value;
public interface DownlinkFactory {
EventDownlink<Value> downlink();
ListDownlink<Value> downlinkList();
MapDownlink<Value, Value> downlinkMap();
ValueDownlink<Value> downlinkValue();
<V> HttpDownlink<V> downlinkHttp();
<I, O> WsDownlink<I, O> downlinkWs();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/DownlinkRecord.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import swim.api.Downlink;
import swim.dataflow.AbstractRecordOutlet;
public abstract class DownlinkRecord extends AbstractRecordOutlet {
public abstract Downlink downlink();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/DownlinkStreamlet.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import swim.api.Downlink;
import swim.api.ref.SwimRef;
import swim.dataflow.AbstractRecordStreamlet;
import swim.dataflow.Transmuter;
import swim.streamlet.Inout;
import swim.streamlet.Inoutlet;
import swim.streamlet.Out;
import swim.streamlet.Outlet;
import swim.streamlet.StreamletScope;
import swim.structure.Form;
import swim.structure.Value;
public class DownlinkStreamlet extends AbstractRecordStreamlet<Value, Value> {
protected final SwimRef swim;
protected Downlink downlink;
protected DownlinkRecord downlinkRecord;
protected String inputHostUri;
protected String inputNodeUri;
protected String inputLaneUri;
protected float inputPrio;
protected float inputRate;
protected Value inputBody;
protected String inputType;
public DownlinkStreamlet(SwimRef swim, StreamletScope<? extends Value> scope) {
super(scope);
this.swim = swim;
}
public DownlinkStreamlet(SwimRef swim) {
this(swim, null);
}
@Inout
public final Inoutlet<Value, Value> hostUri = inoutlet();
@Inout
public final Inoutlet<Value, Value> nodeUri = inoutlet();
@Inout
public final Inoutlet<Value, Value> laneUri = inoutlet();
@Inout
public final Inoutlet<Value, Value> prio = inoutlet();
@Inout
public final Inoutlet<Value, Value> rate = inoutlet();
@Inout
public final Inoutlet<Value, Value> body = inoutlet();
@Inout
public final Inoutlet<Value, Value> type = inoutlet();
@SuppressWarnings("checkstyle:VisibilityModifier")
@Out
public Outlet<Value> state;
@SuppressWarnings("unchecked")
@Override
public Value getOutput(Outlet<? super Value> outlet) {
if (outlet == this.state) {
if (this.downlink instanceof ValueDownlink) {
return ((ValueDownlink<Value>) this.downlink).get();
} else if (this.downlinkRecord != null) {
return this.downlinkRecord;
}
}
return null;
}
@SuppressWarnings("unchecked")
@Override
protected void onReconcile(int version) {
final String hostUri = this.castInput(this.hostUri, Form.forString());
final String nodeUri = this.castInput(this.nodeUri, Form.forString());
final String laneUri = this.castInput(this.laneUri, Form.forString());
final float prio = this.castInput(this.prio, Form.forFloat(), 0f);
final float rate = this.castInput(this.rate, Form.forFloat(), 0f);
final Value body = this.getInput(this.body);
final String type = this.castInput(this.type, Form.forString());
if ((hostUri == null ? this.inputHostUri != null : !hostUri.equals(this.inputHostUri))
|| (nodeUri == null ? this.inputNodeUri != null : !nodeUri.equals(this.inputNodeUri))
|| (laneUri == null ? this.inputLaneUri != null : !laneUri.equals(this.inputLaneUri))
|| prio != this.inputPrio || rate != this.inputRate
|| (body == null ? this.inputBody != null : !body.equals(this.inputBody))
|| (type == null ? this.inputType != null : !type.equals(this.inputType))) {
if (this.downlink != null) {
this.downlink.close();
this.downlink = null;
this.downlinkRecord = null;
}
this.inputHostUri = hostUri;
this.inputNodeUri = nodeUri;
this.inputLaneUri = laneUri;
this.inputPrio = prio;
this.inputRate = rate;
this.inputBody = body;
this.inputType = type;
final SwimRef swim = this.swim;
if ("map".equals(type)) {
MapDownlink<Value, Value> downlink = swim.downlinkMap();
if (hostUri != null) {
downlink = downlink.hostUri(hostUri);
}
if (nodeUri != null) {
downlink = downlink.nodeUri(nodeUri);
}
if (laneUri != null) {
downlink = downlink.laneUri(laneUri);
}
if (prio != 0f) {
downlink = downlink.prio(prio);
}
if (rate != 0f) {
downlink = downlink.rate(rate);
}
if (body != null) {
downlink = downlink.body(body);
}
downlink = downlink.open();
this.state = (Outlet<Value>) (Outlet<?>) downlink;
this.downlink = downlink;
this.downlinkRecord = new MapDownlinkRecord(downlink);
} else if ("value".equals(type)) {
ValueDownlink<Value> downlink = swim.downlinkValue();
if (hostUri != null) {
downlink = downlink.hostUri(hostUri);
}
if (nodeUri != null) {
downlink = downlink.nodeUri(nodeUri);
}
if (laneUri != null) {
downlink = downlink.laneUri(laneUri);
}
if (prio != 0f) {
downlink = downlink.prio(prio);
}
if (rate != 0f) {
downlink = downlink.rate(rate);
}
if (body != null) {
downlink = downlink.body(body);
}
downlink = downlink.open();
this.state = downlink;
this.downlink = downlink;
}
}
}
public static Transmuter transmuter(SwimRef swim) {
return new DownlinkTransmuter(swim);
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/DownlinkTransmuter.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import swim.api.ref.SwimRef;
import swim.dataflow.RecordModel;
import swim.dataflow.Transmuter;
import swim.structure.Record;
final class DownlinkTransmuter extends Transmuter {
final SwimRef swim;
DownlinkTransmuter(SwimRef swim) {
this.swim = swim;
}
@Override
public Record transmute(RecordModel model) {
if ("link".equals(model.tag())) {
final DownlinkStreamlet streamlet = new DownlinkStreamlet(this.swim, model);
streamlet.compile();
return streamlet;
}
return model;
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/EventDownlink.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import swim.api.function.DidClose;
import swim.api.function.DidConnect;
import swim.api.function.DidDisconnect;
import swim.api.function.DidFail;
import swim.api.warp.WarpDownlink;
import swim.api.warp.function.DidLink;
import swim.api.warp.function.DidReceive;
import swim.api.warp.function.DidSync;
import swim.api.warp.function.DidUnlink;
import swim.api.warp.function.OnEvent;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillLink;
import swim.api.warp.function.WillReceive;
import swim.api.warp.function.WillSync;
import swim.api.warp.function.WillUnlink;
import swim.structure.Form;
import swim.structure.Value;
import swim.uri.Uri;
public interface EventDownlink<V> extends WarpDownlink {
@Override
EventDownlink<V> hostUri(Uri hostUri);
@Override
EventDownlink<V> hostUri(String hostUri);
@Override
EventDownlink<V> nodeUri(Uri nodeUri);
@Override
EventDownlink<V> nodeUri(String nodeUri);
@Override
EventDownlink<V> laneUri(Uri laneUri);
@Override
EventDownlink<V> laneUri(String laneUri);
@Override
EventDownlink<V> prio(float prio);
@Override
EventDownlink<V> rate(float rate);
@Override
EventDownlink<V> body(Value body);
@Override
EventDownlink<V> keepLinked(boolean keepLinked);
@Override
EventDownlink<V> keepSynced(boolean keepSynced);
Form<V> valueForm();
<V2> EventDownlink<V2> valueForm(Form<V2> valueForm);
<V2> EventDownlink<V2> valueClass(Class<V2> valueClass);
@Override
EventDownlink<V> observe(Object observer);
@Override
EventDownlink<V> unobserve(Object observer);
EventDownlink<V> onEvent(OnEvent<V> onEvent);
@Override
EventDownlink<V> willReceive(WillReceive willReceive);
@Override
EventDownlink<V> didReceive(DidReceive didReceive);
@Override
EventDownlink<V> willCommand(WillCommand willCommand);
@Override
EventDownlink<V> willLink(WillLink willLink);
@Override
EventDownlink<V> didLink(DidLink didLink);
@Override
EventDownlink<V> willSync(WillSync willSync);
@Override
EventDownlink<V> didSync(DidSync didSync);
@Override
EventDownlink<V> willUnlink(WillUnlink willUnlink);
@Override
EventDownlink<V> didUnlink(DidUnlink didUnlink);
@Override
EventDownlink<V> didConnect(DidConnect didConnect);
@Override
EventDownlink<V> didDisconnect(DidDisconnect didDisconnect);
@Override
EventDownlink<V> didClose(DidClose didClose);
@Override
EventDownlink<V> didFail(DidFail didFail);
@Override
EventDownlink<V> open();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/ListDownlink.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import swim.api.function.DidClose;
import swim.api.function.DidConnect;
import swim.api.function.DidDisconnect;
import swim.api.function.DidFail;
import swim.api.warp.WarpDownlink;
import swim.api.warp.function.DidLink;
import swim.api.warp.function.DidReceive;
import swim.api.warp.function.DidSync;
import swim.api.warp.function.DidUnlink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillLink;
import swim.api.warp.function.WillReceive;
import swim.api.warp.function.WillSync;
import swim.api.warp.function.WillUnlink;
import swim.observable.ObservableList;
import swim.observable.function.DidClear;
import swim.observable.function.DidDrop;
import swim.observable.function.DidMoveIndex;
import swim.observable.function.DidRemoveIndex;
import swim.observable.function.DidTake;
import swim.observable.function.DidUpdateIndex;
import swim.observable.function.WillClear;
import swim.observable.function.WillDrop;
import swim.observable.function.WillMoveIndex;
import swim.observable.function.WillRemoveIndex;
import swim.observable.function.WillTake;
import swim.observable.function.WillUpdateIndex;
import swim.structure.Form;
import swim.structure.Value;
import swim.uri.Uri;
import swim.util.KeyedList;
public interface ListDownlink<V> extends WarpDownlink, ObservableList<V>, KeyedList<V> {
@Override
ListDownlink<V> hostUri(Uri hostUri);
@Override
ListDownlink<V> hostUri(String hostUri);
@Override
ListDownlink<V> nodeUri(Uri nodeUri);
@Override
ListDownlink<V> nodeUri(String nodeUri);
@Override
ListDownlink<V> laneUri(Uri laneUri);
@Override
ListDownlink<V> laneUri(String laneUri);
@Override
ListDownlink<V> prio(float prio);
@Override
ListDownlink<V> rate(float rate);
@Override
ListDownlink<V> body(Value body);
@Override
ListDownlink<V> keepLinked(boolean keepLinked);
@Override
ListDownlink<V> keepSynced(boolean keepSynced);
boolean isStateful();
ListDownlink<V> isStateful(boolean isStateful);
Form<V> valueForm();
<V2> ListDownlink<V2> valueForm(Form<V2> valueForm);
<V2> ListDownlink<V2> valueClass(Class<V2> valueClass);
@Override
ListDownlink<V> observe(Object observer);
@Override
ListDownlink<V> unobserve(Object observer);
@Override
ListDownlink<V> willUpdate(WillUpdateIndex<V> willUpdate);
@Override
ListDownlink<V> didUpdate(DidUpdateIndex<V> didUpdate);
@Override
ListDownlink<V> willMove(WillMoveIndex<V> willMove);
@Override
ListDownlink<V> didMove(DidMoveIndex<V> didMove);
@Override
ListDownlink<V> willRemove(WillRemoveIndex willRemove);
@Override
ListDownlink<V> didRemove(DidRemoveIndex<V> didRemove);
@Override
ListDownlink<V> willDrop(WillDrop willDrop);
@Override
ListDownlink<V> didDrop(DidDrop didDrop);
@Override
ListDownlink<V> willTake(WillTake willTake);
@Override
ListDownlink<V> didTake(DidTake didTake);
@Override
ListDownlink<V> willClear(WillClear willClear);
@Override
ListDownlink<V> didClear(DidClear didClear);
@Override
ListDownlink<V> willReceive(WillReceive willReceive);
@Override
ListDownlink<V> didReceive(DidReceive didReceive);
@Override
ListDownlink<V> willCommand(WillCommand willCommand);
@Override
ListDownlink<V> willLink(WillLink willLink);
@Override
ListDownlink<V> didLink(DidLink didLink);
@Override
ListDownlink<V> willSync(WillSync willSync);
@Override
ListDownlink<V> didSync(DidSync didSync);
@Override
ListDownlink<V> willUnlink(WillUnlink willUnlink);
@Override
ListDownlink<V> didUnlink(DidUnlink didUnlink);
@Override
ListDownlink<V> didConnect(DidConnect didConnect);
@Override
ListDownlink<V> didDisconnect(DidDisconnect didDisconnect);
@Override
ListDownlink<V> didClose(DidClose didClose);
@Override
ListDownlink<V> didFail(DidFail didFail);
@Override
ListDownlink<V> open();
@Override
void drop(int lower);
@Override
void take(int keep);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/ListDownlinkRecord.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import java.util.Iterator;
import swim.structure.Item;
import swim.structure.Text;
import swim.structure.Value;
import swim.util.Cursor;
public class ListDownlinkRecord extends DownlinkRecord {
protected final ListDownlink<Value> downlink;
public ListDownlinkRecord(ListDownlink<Value> downlink) {
this.downlink = downlink;
}
@Override
public ListDownlink<Value> downlink() {
return this.downlink;
}
@Override
public boolean isEmpty() {
return this.downlink.isEmpty();
}
@Override
public boolean isArray() {
return true;
}
@Override
public boolean isObject() {
return this.downlink.isEmpty();
}
@Override
public int size() {
return this.downlink.size();
}
@Override
public boolean containsKey(Value key) {
return false;
}
@Override
public boolean containsKey(String key) {
return false;
}
@Override
public Value get(Value key) {
return Value.absent();
}
@Override
public Value get(String key) {
return Value.absent();
}
@Override
public Value getAttr(Text key) {
return Value.absent();
}
@Override
public Value getAttr(String key) {
return Value.absent();
}
@Override
public Value getSlot(Value key) {
return Value.absent();
}
@Override
public Value getSlot(String key) {
return Value.absent();
}
@Override
public Item get(int index) {
if (0 <= index && index < this.downlink.size()) {
return this.downlink.get(index);
}
return Item.absent();
}
@Override
public Item getItem(int index) {
return this.downlink.get(index);
}
@Override
public Value put(Value key, Value newValue) {
throw new UnsupportedOperationException();
}
@Override
public Value put(String key, Value newValue) {
throw new UnsupportedOperationException();
}
@Override
public Value putAttr(Text key, Value newValue) {
throw new UnsupportedOperationException();
}
@Override
public Value putAttr(String key, Value newValue) {
throw new UnsupportedOperationException();
}
@Override
public Value putSlot(Value key, Value newValue) {
throw new UnsupportedOperationException();
}
@Override
public Value putSlot(String key, Value newValue) {
throw new UnsupportedOperationException();
}
@Override
public Item setItem(int index, Item newItem) {
return this.downlink.set(index, newItem.toValue());
}
@Override
public boolean add(Item item) {
return this.downlink.add(item.toValue());
}
@Override
public void add(int index, Item item) {
this.downlink.add(index, item.toValue());
}
@Override
public Item remove(int index) {
return this.downlink.remove(index);
}
@Override
public boolean removeKey(Value key) {
return false;
}
@Override
public boolean removeKey(String key) {
return false;
}
@Override
public void clear() {
this.downlink.clear();
}
@Override
public Iterator<Value> keyIterator() {
return Cursor.empty();
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/MapDownlink.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import java.util.Map;
import swim.api.function.DidClose;
import swim.api.function.DidConnect;
import swim.api.function.DidDisconnect;
import swim.api.function.DidFail;
import swim.api.warp.WarpDownlink;
import swim.api.warp.function.DidLink;
import swim.api.warp.function.DidReceive;
import swim.api.warp.function.DidSync;
import swim.api.warp.function.DidUnlink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillLink;
import swim.api.warp.function.WillReceive;
import swim.api.warp.function.WillSync;
import swim.api.warp.function.WillUnlink;
import swim.observable.ObservableOrderedMap;
import swim.observable.function.DidClear;
import swim.observable.function.DidDrop;
import swim.observable.function.DidRemoveKey;
import swim.observable.function.DidTake;
import swim.observable.function.DidUpdateKey;
import swim.observable.function.WillClear;
import swim.observable.function.WillDrop;
import swim.observable.function.WillRemoveKey;
import swim.observable.function.WillTake;
import swim.observable.function.WillUpdateKey;
import swim.streamlet.MapInlet;
import swim.streamlet.MapOutlet;
import swim.structure.Form;
import swim.structure.Value;
import swim.uri.Uri;
import swim.util.Cursor;
public interface MapDownlink<K, V> extends WarpDownlink, ObservableOrderedMap<K, V>, MapInlet<K, V, Map<K, V>>, MapOutlet<K, V, MapDownlink<K, V>> {
@Override
MapDownlink<K, V> hostUri(Uri hostUri);
@Override
MapDownlink<K, V> hostUri(String hostUri);
@Override
MapDownlink<K, V> nodeUri(Uri nodeUri);
@Override
MapDownlink<K, V> nodeUri(String nodeUri);
@Override
MapDownlink<K, V> laneUri(Uri laneUri);
@Override
MapDownlink<K, V> laneUri(String laneUri);
@Override
MapDownlink<K, V> prio(float prio);
@Override
MapDownlink<K, V> rate(float rate);
@Override
MapDownlink<K, V> body(Value body);
@Override
MapDownlink<K, V> keepLinked(boolean keepLinked);
@Override
MapDownlink<K, V> keepSynced(boolean keepSynced);
boolean isStateful();
MapDownlink<K, V> isStateful(boolean isStateful);
Form<K> keyForm();
<K2> MapDownlink<K2, V> keyForm(Form<K2> keyForm);
<K2> MapDownlink<K2, V> keyClass(Class<K2> keyClass);
Form<V> valueForm();
<V2> MapDownlink<K, V2> valueForm(Form<V2> valueForm);
<V2> MapDownlink<K, V2> valueClass(Class<V2> valueClass);
@Override
MapDownlink<K, V> observe(Object observer);
@Override
MapDownlink<K, V> unobserve(Object observer);
@Override
MapDownlink<K, V> willUpdate(WillUpdateKey<K, V> willUpdate);
@Override
MapDownlink<K, V> didUpdate(DidUpdateKey<K, V> didUpdate);
@Override
MapDownlink<K, V> willRemove(WillRemoveKey<K> willRemove);
@Override
MapDownlink<K, V> didRemove(DidRemoveKey<K, V> didRemove);
@Override
MapDownlink<K, V> willDrop(WillDrop willDrop);
@Override
MapDownlink<K, V> didDrop(DidDrop didDrop);
@Override
MapDownlink<K, V> willTake(WillTake willTake);
@Override
MapDownlink<K, V> didTake(DidTake didTake);
@Override
MapDownlink<K, V> willClear(WillClear willClear);
@Override
MapDownlink<K, V> didClear(DidClear didClear);
@Override
MapDownlink<K, V> willReceive(WillReceive willReceive);
@Override
MapDownlink<K, V> didReceive(DidReceive didReceive);
@Override
MapDownlink<K, V> willCommand(WillCommand willCommand);
@Override
MapDownlink<K, V> willLink(WillLink willLink);
@Override
MapDownlink<K, V> didLink(DidLink didLink);
@Override
MapDownlink<K, V> willSync(WillSync willSync);
@Override
MapDownlink<K, V> didSync(DidSync didSync);
@Override
MapDownlink<K, V> willUnlink(WillUnlink willUnlink);
@Override
MapDownlink<K, V> didUnlink(DidUnlink didUnlink);
@Override
MapDownlink<K, V> didConnect(DidConnect didConnect);
@Override
MapDownlink<K, V> didDisconnect(DidDisconnect didDisconnect);
@Override
MapDownlink<K, V> didClose(DidClose didClose);
@Override
MapDownlink<K, V> didFail(DidFail didFail);
@Override
MapDownlink<K, V> open();
@Override
Cursor<K> keyIterator();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/MapDownlinkRecord.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import java.util.Iterator;
import java.util.Map;
import swim.observable.function.DidClear;
import swim.observable.function.DidDrop;
import swim.observable.function.DidRemoveKey;
import swim.observable.function.DidTake;
import swim.observable.function.DidUpdateKey;
import swim.streamlet.KeyEffect;
import swim.structure.Item;
import swim.structure.Slot;
import swim.structure.Text;
import swim.structure.Value;
public class MapDownlinkRecord extends DownlinkRecord
implements DidUpdateKey<Value, Value>, DidRemoveKey<Value, Value>,
DidDrop, DidTake, DidClear {
protected final MapDownlink<Value, Value> downlink;
public MapDownlinkRecord(MapDownlink<Value, Value> downlink) {
this.downlink = downlink;
this.downlink.observe(this);
}
@Override
public MapDownlink<Value, Value> downlink() {
return this.downlink;
}
@Override
public boolean isEmpty() {
return this.downlink.isEmpty();
}
@Override
public boolean isArray() {
return this.downlink.isEmpty();
}
@Override
public boolean isObject() {
return true;
}
@Override
public int size() {
return this.downlink.size();
}
@Override
public boolean containsKey(Value key) {
return this.downlink.containsKey(key);
}
@Override
public boolean containsKey(String key) {
return this.downlink.containsKey(Text.from(key));
}
@Override
public Value get(Value key) {
return this.downlink.get(key);
}
@Override
public Value get(String key) {
return this.downlink.get(key);
}
@Override
public Value getAttr(Text key) {
return Value.absent();
}
@Override
public Value getAttr(String key) {
return Value.absent();
}
@Override
public Value getSlot(Value key) {
return get(key);
}
@Override
public Value getSlot(String key) {
return get(key);
}
@Override
public Item get(int index) {
final Map.Entry<Value, Value> entry = this.downlink.getEntry(index);
if (entry != null) {
return Slot.of(entry.getKey(), entry.getValue());
} else {
throw new IndexOutOfBoundsException(Integer.toString(index));
}
}
@Override
public Item getItem(int index) {
final Map.Entry<Value, Value> entry = this.downlink.getEntry(index);
if (entry != null) {
return Slot.of(entry.getKey(), entry.getValue());
} else {
return Item.absent();
}
}
@Override
public Value put(Value key, Value newValue) {
return this.downlink.put(key, newValue);
}
@Override
public Value put(String key, Value newValue) {
return this.downlink.put(Text.from(key), newValue);
}
@Override
public Value putAttr(Text key, Value newValue) {
throw new UnsupportedOperationException();
}
@Override
public Value putAttr(String key, Value newValue) {
throw new UnsupportedOperationException();
}
@Override
public Value putSlot(Value key, Value newValue) {
return put(key, newValue);
}
@Override
public Value putSlot(String key, Value newValue) {
return put(key, newValue);
}
@Override
public Item setItem(int index, Item newItem) {
throw new UnsupportedOperationException();
}
@Override
public boolean add(Item item) {
throw new UnsupportedOperationException();
}
@Override
public void add(int index, Item item) {
throw new UnsupportedOperationException();
}
@Override
public Item remove(int index) {
throw new UnsupportedOperationException();
}
@Override
public boolean removeKey(Value key) {
return this.downlink.remove(key) != null;
}
@Override
public boolean removeKey(String key) {
return this.downlink.remove(Text.from(key)) != null;
}
@Override
public void clear() {
this.downlink.clear();
}
@Override
public Iterator<Value> keyIterator() {
return this.downlink.keyIterator();
}
@Override
public void didUpdate(Value key, Value newValue, Value oldValue) {
this.invalidateInputKey(key, KeyEffect.UPDATE);
this.reconcileInput(0); // TODO: debounce
}
@Override
public void didRemove(Value key, Value oldValue) {
this.invalidateInputKey(key, KeyEffect.REMOVE);
this.reconcileInput(0); // TODO: debounce
}
@Override
public void didDrop(int lower) {
// TODO
}
@Override
public void didTake(int upper) {
// TODO
}
@Override
public void didClear() {
// TODO
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/ValueDownlink.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import swim.api.function.DidClose;
import swim.api.function.DidConnect;
import swim.api.function.DidDisconnect;
import swim.api.function.DidFail;
import swim.api.warp.WarpDownlink;
import swim.api.warp.function.DidLink;
import swim.api.warp.function.DidReceive;
import swim.api.warp.function.DidSync;
import swim.api.warp.function.DidUnlink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillLink;
import swim.api.warp.function.WillReceive;
import swim.api.warp.function.WillSync;
import swim.api.warp.function.WillUnlink;
import swim.observable.ObservableValue;
import swim.observable.function.DidSet;
import swim.observable.function.WillSet;
import swim.streamlet.Inlet;
import swim.streamlet.Outlet;
import swim.structure.Form;
import swim.structure.Value;
import swim.uri.Uri;
public interface ValueDownlink<V> extends WarpDownlink, ObservableValue<V>, Inlet<V>, Outlet<V> {
@Override
ValueDownlink<V> hostUri(Uri hostUri);
@Override
ValueDownlink<V> hostUri(String hostUri);
@Override
ValueDownlink<V> nodeUri(Uri nodeUri);
@Override
ValueDownlink<V> nodeUri(String nodeUri);
@Override
ValueDownlink<V> laneUri(Uri laneUri);
@Override
ValueDownlink<V> laneUri(String laneUri);
@Override
ValueDownlink<V> prio(float prio);
@Override
ValueDownlink<V> rate(float rate);
@Override
ValueDownlink<V> body(Value body);
@Override
ValueDownlink<V> keepLinked(boolean keepLinked);
@Override
ValueDownlink<V> keepSynced(boolean keepSynced);
boolean isStateful();
ValueDownlink<V> isStateful(boolean isStateful);
Form<V> valueForm();
<V2> ValueDownlink<V2> valueForm(Form<V2> valueForm);
<V2> ValueDownlink<V2> valueClass(Class<V2> valueClass);
@Override
ValueDownlink<V> observe(Object observer);
@Override
ValueDownlink<V> unobserve(Object observer);
@Override
ValueDownlink<V> willSet(WillSet<V> willSet);
@Override
ValueDownlink<V> didSet(DidSet<V> didSet);
@Override
ValueDownlink<V> willReceive(WillReceive willReceive);
@Override
ValueDownlink<V> didReceive(DidReceive didReceive);
@Override
ValueDownlink<V> willCommand(WillCommand willCommand);
@Override
ValueDownlink<V> willLink(WillLink willLink);
@Override
ValueDownlink<V> didLink(DidLink didLink);
@Override
ValueDownlink<V> willSync(WillSync willSync);
@Override
ValueDownlink<V> didSync(DidSync didSync);
@Override
ValueDownlink<V> willUnlink(WillUnlink willUnlink);
@Override
ValueDownlink<V> didUnlink(DidUnlink didUnlink);
@Override
ValueDownlink<V> didConnect(DidConnect didConnect);
@Override
ValueDownlink<V> didDisconnect(DidDisconnect didDisconnect);
@Override
ValueDownlink<V> didClose(DidClose didClose);
@Override
ValueDownlink<V> didFail(DidFail didFail);
@Override
ValueDownlink<V> open();
@Override
V get();
@Override
V set(V newValue);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/ValueDownlinkRecord.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.downlink;
import java.util.Iterator;
import swim.observable.function.DidSet;
import swim.structure.Field;
import swim.structure.Item;
import swim.structure.Record;
import swim.structure.Text;
import swim.structure.Value;
import swim.util.Cursor;
public class ValueDownlinkRecord extends DownlinkRecord implements DidSet<Value> {
protected final ValueDownlink<Value> downlink;
public ValueDownlinkRecord(ValueDownlink<Value> downlink) {
this.downlink = downlink;
this.downlink.observe(this);
}
@Override
public ValueDownlink<Value> downlink() {
return this.downlink;
}
@Override
public boolean isEmpty() {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).isEmpty();
} else {
return !value.isDefined();
}
}
@Override
public boolean isArray() {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).isArray();
} else {
return true;
}
}
@Override
public boolean isObject() {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).isObject();
} else {
return !value.isDefined();
}
}
@Override
public int size() {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).size();
} else if (value.isDefined()) {
return 1;
} else {
return 0;
}
}
@Override
public boolean containsKey(Value key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).containsKey(key);
} else {
return false;
}
}
@Override
public boolean containsKey(String key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).containsKey(key);
} else {
return false;
}
}
@Override
public Value get(Value key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).get(key);
} else {
return Value.absent();
}
}
@Override
public Value get(String key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).get(key);
} else {
return Value.absent();
}
}
@Override
public Value getAttr(Text key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).getAttr(key);
} else {
return Value.absent();
}
}
@Override
public Value getAttr(String key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).getAttr(key);
} else {
return Value.absent();
}
}
@Override
public Value getSlot(Value key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).getSlot(key);
} else {
return Value.absent();
}
}
@Override
public Value getSlot(String key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).getSlot(key);
} else {
return Value.absent();
}
}
@Override
public Field getField(Value key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).getField(key);
} else {
return null;
}
}
@Override
public Field getField(String key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).getField(key);
} else {
return null;
}
}
@Override
public Item get(int index) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).getItem(index);
} else {
throw new IndexOutOfBoundsException(Integer.toString(index));
}
}
@Override
public Item getItem(int index) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).getItem(index);
} else if (index == 0) {
return value;
} else {
return Item.absent();
}
}
@Override
public Value put(Value key, Value newValue) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).put(key, newValue);
} else {
throw new UnsupportedOperationException();
}
}
@Override
public Value put(String key, Value newValue) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).put(key, newValue);
} else {
throw new UnsupportedOperationException();
}
}
@Override
public Value putAttr(Text key, Value newValue) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).putAttr(key, newValue);
} else {
throw new UnsupportedOperationException();
}
}
@Override
public Value putAttr(String key, Value newValue) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).putAttr(key, newValue);
} else {
throw new UnsupportedOperationException();
}
}
@Override
public Value putSlot(Value key, Value newValue) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).putSlot(key, newValue);
} else {
throw new UnsupportedOperationException();
}
}
@Override
public Value putSlot(String key, Value newValue) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).putSlot(key, newValue);
} else {
throw new UnsupportedOperationException();
}
}
@Override
public Item setItem(int index, Item newItem) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).setItem(index, newItem);
} else if (index == 0) {
return this.downlink.set(newItem.toValue());
} else {
throw new IndexOutOfBoundsException(Integer.toString(index));
}
}
@Override
public boolean add(Item item) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).add(item);
} else {
throw new UnsupportedOperationException();
}
}
@Override
public void add(int index, Item item) {
final Value value = this.downlink.get();
if (value instanceof Record) {
((Record) value).add(index, item);
} else {
throw new UnsupportedOperationException();
}
}
@Override
public Item remove(int index) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).remove(index);
} else {
throw new IndexOutOfBoundsException(Integer.toString(index));
}
}
@Override
public boolean removeKey(Value key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).removeKey(key);
} else {
return false;
}
}
@Override
public boolean removeKey(String key) {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).removeKey(key);
} else {
return false;
}
}
@Override
public void clear() {
final Value value = this.downlink.get();
if (value instanceof Record) {
((Record) value).clear();
} else {
throw new UnsupportedOperationException();
}
}
@Override
public Iterator<Value> keyIterator() {
final Value value = this.downlink.get();
if (value instanceof Record) {
return ((Record) value).keyIterator();
} else {
return Cursor.empty();
}
}
@Override
public void didSet(Value newValue, Value oldValue) {
this.invalidateInput();
this.reconcileInput(0); // TODO: debounce
}
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/downlink/package-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Stateful, read- and write-capable, subscriptions to {@link swim.api.Lane
* Lanes}.
*/
package swim.api.downlink;
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/function/DidClose.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.function;
import swim.concurrent.Preemptive;
@FunctionalInterface
public interface DidClose extends Preemptive {
void didClose();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/function/DidConnect.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.function;
import swim.concurrent.Preemptive;
@FunctionalInterface
public interface DidConnect extends Preemptive {
void didConnect();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/function/DidDisconnect.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.function;
import swim.concurrent.Preemptive;
@FunctionalInterface
public interface DidDisconnect extends Preemptive {
void didDisconnect();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/function/DidFail.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.function;
import swim.concurrent.Preemptive;
@FunctionalInterface
public interface DidFail extends Preemptive {
void didFail(Throwable error);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/function/package-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Lifecycle callback function interfaces.
*/
package swim.api.function;
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/HttpDownlink.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http;
import swim.api.Downlink;
import swim.api.function.DidClose;
import swim.api.function.DidConnect;
import swim.api.function.DidDisconnect;
import swim.api.function.DidFail;
import swim.api.http.function.DecodeResponseHttp;
import swim.api.http.function.DidRequestHttp;
import swim.api.http.function.DidRespondHttp;
import swim.api.http.function.DoRequestHttp;
import swim.api.http.function.WillRequestHttp;
import swim.api.http.function.WillRespondHttp;
import swim.uri.Uri;
public interface HttpDownlink<V> extends Downlink, HttpLink {
HttpDownlink<V> requestUri(Uri requestUri);
@Override
HttpDownlink<V> observe(Object observer);
@Override
HttpDownlink<V> unobserve(Object observer);
HttpDownlink<V> doRequest(DoRequestHttp<?> doRequest);
HttpDownlink<V> willRequest(WillRequestHttp<?> willRequest);
HttpDownlink<V> didRequest(DidRequestHttp<?> didRequest);
HttpDownlink<V> decodeResponse(DecodeResponseHttp<V> decodeResponse);
HttpDownlink<V> willRespond(WillRespondHttp<V> willRespond);
HttpDownlink<V> didRespond(DidRespondHttp<V> didRespond);
@Override
HttpDownlink<V> didConnect(DidConnect didConnect);
@Override
HttpDownlink<V> didDisconnect(DidDisconnect didDisconnect);
@Override
HttpDownlink<V> didClose(DidClose didClose);
@Override
HttpDownlink<V> didFail(DidFail didFail);
@Override
HttpDownlink<V> open();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/HttpLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http;
import swim.api.Lane;
import swim.api.http.function.DecodeRequestHttp;
import swim.api.http.function.DidRequestHttp;
import swim.api.http.function.DidRespondHttp;
import swim.api.http.function.DoRespondHttp;
import swim.api.http.function.WillRequestHttp;
import swim.api.http.function.WillRespondHttp;
public interface HttpLane<V> extends Lane {
@Override
HttpLane<V> observe(Object observer);
@Override
HttpLane<V> unobserve(Object observer);
HttpLane<V> decodeRequest(DecodeRequestHttp<V> decodeRequest);
HttpLane<V> willRequest(WillRequestHttp<?> willRequest);
HttpLane<V> didRequest(DidRequestHttp<V> didRequest);
HttpLane<V> doRespond(DoRespondHttp<V> doRespond);
HttpLane<V> willRespond(WillRespondHttp<?> willRespond);
HttpLane<V> didRespond(DidRespondHttp<?> didRespond);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/HttpLink.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http;
import swim.api.Link;
import swim.uri.Uri;
public interface HttpLink extends Link {
Uri requestUri();
@Override
HttpLink observe(Object observer);
@Override
HttpLink unobserve(Object observer);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/HttpUplink.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http;
import swim.api.Uplink;
import swim.http.HttpRequest;
public interface HttpUplink extends Uplink, HttpLink {
HttpRequest<?> request();
@Override
HttpUplink observe(Object observer);
@Override
HttpUplink unobserve(Object observer);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/package-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* HTTP lanes and downlinks.
*/
package swim.api.http;
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api/http | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/function/DecodeRequestHttp.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http.function;
import swim.codec.Decoder;
import swim.concurrent.Preemptive;
import swim.http.HttpRequest;
@FunctionalInterface
public interface DecodeRequestHttp<V> extends Preemptive {
Decoder<V> decodeRequest(HttpRequest<?> request);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api/http | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/function/DecodeResponseHttp.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http.function;
import swim.codec.Decoder;
import swim.concurrent.Preemptive;
import swim.http.HttpResponse;
@FunctionalInterface
public interface DecodeResponseHttp<V> extends Preemptive {
Decoder<V> decodeResponse(HttpResponse<?> response);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api/http | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/function/DidRequestHttp.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http.function;
import swim.concurrent.Preemptive;
import swim.http.HttpRequest;
@FunctionalInterface
public interface DidRequestHttp<V> extends Preemptive {
void didRequest(HttpRequest<V> request);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api/http | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/function/DidRespondHttp.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http.function;
import swim.concurrent.Preemptive;
import swim.http.HttpResponse;
@FunctionalInterface
public interface DidRespondHttp<V> extends Preemptive {
void didRespond(HttpResponse<V> response);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api/http | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/function/DoRequestHttp.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http.function;
import swim.concurrent.Preemptive;
import swim.http.HttpRequest;
@FunctionalInterface
public interface DoRequestHttp<V> extends Preemptive {
HttpRequest<V> doRequest();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api/http | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/function/DoRespondHttp.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http.function;
import swim.concurrent.Preemptive;
import swim.http.HttpRequest;
import swim.http.HttpResponse;
@FunctionalInterface
public interface DoRespondHttp<V> extends Preemptive {
HttpResponse<?> doRespond(HttpRequest<V> request);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api/http | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/function/WillRequestHttp.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http.function;
import swim.concurrent.Preemptive;
import swim.http.HttpRequest;
@FunctionalInterface
public interface WillRequestHttp<V> extends Preemptive {
void willRequest(HttpRequest<V> request);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api/http | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/function/WillRespondHttp.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.http.function;
import swim.concurrent.Preemptive;
import swim.http.HttpResponse;
@FunctionalInterface
public interface WillRespondHttp<V> extends Preemptive {
void willRespond(HttpResponse<V> response);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api/http | java-sources/ai/swim/swim-api/3.10.0/swim/api/http/function/package-info.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* HTTP lane and downlink callback function interfaces.
*/
package swim.api.http.function;
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/CommandLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import swim.api.warp.WarpLane;
import swim.api.warp.function.DidCommand;
import swim.api.warp.function.DidEnter;
import swim.api.warp.function.DidLeave;
import swim.api.warp.function.DidUplink;
import swim.api.warp.function.OnCommand;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillEnter;
import swim.api.warp.function.WillLeave;
import swim.api.warp.function.WillUplink;
import swim.structure.Form;
public interface CommandLane<V> extends WarpLane {
Form<V> valueForm();
<V2> CommandLane<V2> valueForm(Form<V2> valueForm);
<V2> CommandLane<V2> valueClass(Class<V2> valueClass);
@Override
CommandLane<V> observe(Object observer);
@Override
CommandLane<V> unobserve(Object observer);
CommandLane<V> onCommand(OnCommand<V> value);
@Override
CommandLane<V> willCommand(WillCommand willCommand);
@Override
CommandLane<V> didCommand(DidCommand didCommand);
@Override
CommandLane<V> willUplink(WillUplink willUplink);
@Override
CommandLane<V> didUplink(DidUplink didUplink);
@Override
CommandLane<V> willEnter(WillEnter willEnter);
@Override
CommandLane<V> didEnter(DidEnter didEnter);
@Override
CommandLane<V> willLeave(WillLeave willLeave);
@Override
CommandLane<V> didLeave(DidLeave didLeave);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/DemandLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import swim.api.lane.function.OnCue;
import swim.api.warp.WarpLane;
import swim.api.warp.function.DidCommand;
import swim.api.warp.function.DidEnter;
import swim.api.warp.function.DidLeave;
import swim.api.warp.function.DidUplink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillEnter;
import swim.api.warp.function.WillLeave;
import swim.api.warp.function.WillUplink;
import swim.structure.Form;
public interface DemandLane<V> extends WarpLane {
Form<V> valueForm();
<V2> DemandLane<V2> valueForm(Form<V2> valueForm);
<V2> DemandLane<V2> valueClass(Class<V2> valueClass);
@Override
DemandLane<V> observe(Object observer);
@Override
DemandLane<V> unobserve(Object observer);
DemandLane<V> onCue(OnCue<V> onCue);
@Override
DemandLane<V> willCommand(WillCommand willCommand);
@Override
DemandLane<V> didCommand(DidCommand didCommand);
@Override
DemandLane<V> willUplink(WillUplink willUplink);
@Override
DemandLane<V> didUplink(DidUplink didUplink);
@Override
DemandLane<V> willEnter(WillEnter willEnter);
@Override
DemandLane<V> didEnter(DidEnter didEnter);
@Override
DemandLane<V> willLeave(WillLeave willLeave);
@Override
DemandLane<V> didLeave(DidLeave didLeave);
void cue();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/DemandMapLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import swim.api.lane.function.OnCueKey;
import swim.api.lane.function.OnSyncMap;
import swim.api.warp.WarpLane;
import swim.api.warp.function.DidCommand;
import swim.api.warp.function.DidEnter;
import swim.api.warp.function.DidLeave;
import swim.api.warp.function.DidUplink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillEnter;
import swim.api.warp.function.WillLeave;
import swim.api.warp.function.WillUplink;
import swim.structure.Form;
public interface DemandMapLane<K, V> extends WarpLane {
Form<K> keyForm();
<K2> DemandMapLane<K2, V> keyForm(Form<K2> keyForm);
<K2> DemandMapLane<K2, V> keyClass(Class<K2> keyClass);
Form<V> valueForm();
<V2> DemandMapLane<K, V2> valueForm(Form<V2> valueForm);
<V2> DemandMapLane<K, V2> valueClass(Class<V2> valueClass);
@Override
DemandMapLane<K, V> observe(Object observer);
@Override
DemandMapLane<K, V> unobserve(Object observer);
DemandMapLane<K, V> onCue(OnCueKey<K, V> onCue);
DemandMapLane<K, V> onSync(OnSyncMap<K, V> onSync);
@Override
DemandMapLane<K, V> willCommand(WillCommand willCommand);
@Override
DemandMapLane<K, V> didCommand(DidCommand didCommand);
@Override
DemandMapLane<K, V> willUplink(WillUplink willUplink);
@Override
DemandMapLane<K, V> didUplink(DidUplink didUplink);
@Override
DemandMapLane<K, V> willEnter(WillEnter willEnter);
@Override
DemandMapLane<K, V> didEnter(DidEnter didEnter);
@Override
DemandMapLane<K, V> willLeave(WillLeave willLeave);
@Override
DemandMapLane<K, V> didLeave(DidLeave didLeave);
void cue(K key);
void remove(K key);
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/JoinMapLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import java.util.Iterator;
import java.util.Map;
import swim.api.downlink.MapDownlink;
import swim.api.lane.function.DidDownlinkMap;
import swim.api.lane.function.WillDownlinkMap;
import swim.api.warp.WarpLane;
import swim.api.warp.function.DidCommand;
import swim.api.warp.function.DidEnter;
import swim.api.warp.function.DidLeave;
import swim.api.warp.function.DidUplink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillEnter;
import swim.api.warp.function.WillLeave;
import swim.api.warp.function.WillUplink;
import swim.observable.ObservableMap;
import swim.observable.function.DidClear;
import swim.observable.function.DidRemoveKey;
import swim.observable.function.DidUpdateKey;
import swim.observable.function.WillClear;
import swim.observable.function.WillRemoveKey;
import swim.observable.function.WillUpdateKey;
import swim.structure.Form;
public interface JoinMapLane<L, K, V> extends WarpLane, Iterable<Map.Entry<K, V>>, ObservableMap<K, V> {
Form<L> linkForm();
<L2> JoinMapLane<L2, K, V> linkForm(Form<L2> linkForm);
<L2> JoinMapLane<L2, K, V> linkClass(Class<L2> linkClass);
Form<K> keyForm();
<K2> JoinMapLane<L, K2, V> keyForm(Form<K2> keyForm);
<K2> JoinMapLane<L, K2, V> keyClass(Class<K2> keyClass);
Form<V> valueForm();
<V2> JoinMapLane<L, K, V2> valueForm(Form<V2> valueForm);
<V2> JoinMapLane<L, K, V2> valueClass(Class<V2> valueClass);
boolean isResident();
JoinMapLane<L, K, V> isResident(boolean isResident);
boolean isTransient();
JoinMapLane<L, K, V> isTransient(boolean isTransient);
@Override
JoinMapLane<L, K, V> observe(Object observer);
@Override
JoinMapLane<L, K, V> unobserve(Object observer);
JoinMapLane<L, K, V> willDownlink(WillDownlinkMap<L> willDownlink);
JoinMapLane<L, K, V> didDownlink(DidDownlinkMap<L> didDownlink);
@Override
JoinMapLane<L, K, V> willUpdate(WillUpdateKey<K, V> willUpdate);
@Override
JoinMapLane<L, K, V> didUpdate(DidUpdateKey<K, V> didUpdate);
@Override
JoinMapLane<L, K, V> willRemove(WillRemoveKey<K> willRemove);
@Override
JoinMapLane<L, K, V> didRemove(DidRemoveKey<K, V> didRemove);
@Override
JoinMapLane<L, K, V> willClear(WillClear willClear);
@Override
JoinMapLane<L, K, V> didClear(DidClear didClear);
@Override
JoinMapLane<L, K, V> willCommand(WillCommand willCommand);
@Override
JoinMapLane<L, K, V> didCommand(DidCommand didCommand);
@Override
JoinMapLane<L, K, V> willUplink(WillUplink willUplink);
@Override
JoinMapLane<L, K, V> didUplink(DidUplink didUplink);
@Override
JoinMapLane<L, K, V> willEnter(WillEnter willEnter);
@Override
JoinMapLane<L, K, V> didEnter(DidEnter didEnter);
@Override
JoinMapLane<L, K, V> willLeave(WillLeave willLeave);
@Override
JoinMapLane<L, K, V> didLeave(DidLeave didLeave);
MapDownlink<K, V> downlink(L key);
MapDownlink<?, ?> getDownlink(Object key);
Iterator<K> keyIterator();
Iterator<V> valueIterator();
Iterator<Entry<L, MapDownlink<?, ?>>> downlinkIterator();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/JoinValueLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import java.util.Iterator;
import java.util.Map;
import swim.api.downlink.ValueDownlink;
import swim.api.lane.function.DidDownlinkValue;
import swim.api.lane.function.WillDownlinkValue;
import swim.api.warp.WarpLane;
import swim.api.warp.function.DidCommand;
import swim.api.warp.function.DidEnter;
import swim.api.warp.function.DidLeave;
import swim.api.warp.function.DidUplink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillEnter;
import swim.api.warp.function.WillLeave;
import swim.api.warp.function.WillUplink;
import swim.observable.ObservableMap;
import swim.observable.function.DidClear;
import swim.observable.function.DidRemoveKey;
import swim.observable.function.DidUpdateKey;
import swim.observable.function.WillClear;
import swim.observable.function.WillRemoveKey;
import swim.observable.function.WillUpdateKey;
import swim.structure.Form;
public interface JoinValueLane<K, V> extends WarpLane, Iterable<Map.Entry<K, V>>, ObservableMap<K, V> {
Form<K> keyForm();
<K2> JoinValueLane<K2, V> keyForm(Form<K2> keyForm);
<K2> JoinValueLane<K2, V> keyClass(Class<K2> keyClass);
Form<V> valueForm();
<V2> JoinValueLane<K, V2> valueForm(Form<V2> valueForm);
<V2> JoinValueLane<K, V2> valueClass(Class<V2> valueClass);
boolean isResident();
JoinValueLane<K, V> isResident(boolean isResident);
boolean isTransient();
JoinValueLane<K, V> isTransient(boolean isTransient);
@Override
JoinValueLane<K, V> observe(Object observer);
@Override
JoinValueLane<K, V> unobserve(Object observer);
JoinValueLane<K, V> willDownlink(WillDownlinkValue<K> willDownlink);
JoinValueLane<K, V> didDownlink(DidDownlinkValue<K> didDownlink);
@Override
JoinValueLane<K, V> willUpdate(WillUpdateKey<K, V> willUpdate);
@Override
JoinValueLane<K, V> didUpdate(DidUpdateKey<K, V> didUpdate);
@Override
JoinValueLane<K, V> willRemove(WillRemoveKey<K> willRemove);
@Override
JoinValueLane<K, V> didRemove(DidRemoveKey<K, V> didRemove);
@Override
JoinValueLane<K, V> willClear(WillClear willClear);
@Override
JoinValueLane<K, V> didClear(DidClear didClear);
@Override
JoinValueLane<K, V> willCommand(WillCommand willCommand);
@Override
JoinValueLane<K, V> didCommand(DidCommand didCommand);
@Override
JoinValueLane<K, V> willUplink(WillUplink willUplink);
@Override
JoinValueLane<K, V> didUplink(DidUplink didUplink);
@Override
JoinValueLane<K, V> willEnter(WillEnter willEnter);
@Override
JoinValueLane<K, V> didEnter(DidEnter didEnter);
@Override
JoinValueLane<K, V> willLeave(WillLeave willLeave);
@Override
JoinValueLane<K, V> didLeave(DidLeave didLeave);
ValueDownlink<V> downlink(K key);
ValueDownlink<?> getDownlink(Object key);
Iterator<K> keyIterator();
Iterator<V> valueIterator();
Iterator<Entry<K, ValueDownlink<?>>> downlinkIterator();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/LaneFactory.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import swim.api.http.HttpLane;
import swim.api.ws.WsLane;
import swim.math.R2Shape;
import swim.math.Z2Form;
public interface LaneFactory {
<V> CommandLane<V> commandLane();
<V> DemandLane<V> demandLane();
<K, V> DemandMapLane<K, V> demandMapLane();
<V> HttpLane<V> httpLane();
<L, K, V> JoinMapLane<L, K, V> joinMapLane();
<K, V> JoinValueLane<K, V> joinValueLane();
<V> ListLane<V> listLane();
<K, V> MapLane<K, V> mapLane();
<K, S, V> SpatialLane<K, S, V> spatialLane(Z2Form<S> shapeForm);
<K, V> SpatialLane<K, R2Shape, V> geospatialLane();
<V> SupplyLane<V> supplyLane();
<V> ValueLane<V> valueLane();
<I, O> WsLane<I, O> wsLane();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/ListLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import java.util.List;
import swim.api.warp.WarpLane;
import swim.api.warp.function.DidCommand;
import swim.api.warp.function.DidEnter;
import swim.api.warp.function.DidLeave;
import swim.api.warp.function.DidUplink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillEnter;
import swim.api.warp.function.WillLeave;
import swim.api.warp.function.WillUplink;
import swim.observable.ObservableList;
import swim.observable.function.DidClear;
import swim.observable.function.DidDrop;
import swim.observable.function.DidMoveIndex;
import swim.observable.function.DidRemoveIndex;
import swim.observable.function.DidTake;
import swim.observable.function.DidUpdateIndex;
import swim.observable.function.WillClear;
import swim.observable.function.WillDrop;
import swim.observable.function.WillMoveIndex;
import swim.observable.function.WillRemoveIndex;
import swim.observable.function.WillTake;
import swim.observable.function.WillUpdateIndex;
import swim.structure.Form;
import swim.util.KeyedList;
public interface ListLane<V> extends WarpLane, KeyedList<V>, ObservableList<V> {
Form<V> valueForm();
<V2> ListLane<V2> valueForm(Form<V2> valueForm);
<V2> ListLane<V2> valueClass(Class<V2> valueClass);
boolean isResident();
ListLane<V> isResident(boolean isResident);
boolean isTransient();
ListLane<V> isTransient(boolean isTransient);
@Override
ListLane<V> observe(Object observer);
@Override
ListLane<V> unobserve(Object observer);
@Override
ListLane<V> willUpdate(WillUpdateIndex<V> willUpdate);
@Override
ListLane<V> didUpdate(DidUpdateIndex<V> didUpdate);
@Override
ListLane<V> willMove(WillMoveIndex<V> willMove);
@Override
ListLane<V> didMove(DidMoveIndex<V> didMove);
@Override
ListLane<V> willRemove(WillRemoveIndex willRemove);
@Override
ListLane<V> didRemove(DidRemoveIndex<V> didRemove);
@Override
ListLane<V> willDrop(WillDrop willDrop);
@Override
ListLane<V> didDrop(DidDrop didDrop);
@Override
ListLane<V> willTake(WillTake willTake);
@Override
ListLane<V> didTake(DidTake didTake);
@Override
ListLane<V> willClear(WillClear willClear);
@Override
ListLane<V> didClear(DidClear didClear);
@Override
ListLane<V> willCommand(WillCommand willCommand);
@Override
ListLane<V> didCommand(DidCommand didCommand);
@Override
ListLane<V> willUplink(WillUplink willUplink);
@Override
ListLane<V> didUplink(DidUplink didUplink);
@Override
ListLane<V> willEnter(WillEnter willEnter);
@Override
ListLane<V> didEnter(DidEnter didEnter);
@Override
ListLane<V> willLeave(WillLeave willLeave);
@Override
ListLane<V> didLeave(DidLeave didLeave);
@Override
void drop(int lower);
@Override
void take(int keep);
List<V> snapshot();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/MapLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import java.util.Map;
import swim.api.warp.WarpLane;
import swim.api.warp.function.DidCommand;
import swim.api.warp.function.DidEnter;
import swim.api.warp.function.DidLeave;
import swim.api.warp.function.DidUplink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillEnter;
import swim.api.warp.function.WillLeave;
import swim.api.warp.function.WillUplink;
import swim.observable.ObservableOrderedMap;
import swim.observable.function.DidClear;
import swim.observable.function.DidDrop;
import swim.observable.function.DidRemoveKey;
import swim.observable.function.DidTake;
import swim.observable.function.DidUpdateKey;
import swim.observable.function.WillClear;
import swim.observable.function.WillDrop;
import swim.observable.function.WillRemoveKey;
import swim.observable.function.WillTake;
import swim.observable.function.WillUpdateKey;
import swim.streamlet.MapInlet;
import swim.streamlet.MapOutlet;
import swim.structure.Form;
import swim.util.Cursor;
import swim.util.OrderedMap;
public interface MapLane<K, V> extends WarpLane, ObservableOrderedMap<K, V>, MapInlet<K, V, Map<K, V>>, MapOutlet<K, V, MapLane<K, V>> {
Form<K> keyForm();
<K2> MapLane<K2, V> keyForm(Form<K2> keyForm);
<K2> MapLane<K2, V> keyClass(Class<K2> keyClass);
Form<V> valueForm();
<V2> MapLane<K, V2> valueForm(Form<V2> valueForm);
<V2> MapLane<K, V2> valueClass(Class<V2> valueClass);
boolean isResident();
MapLane<K, V> isResident(boolean isResident);
boolean isTransient();
MapLane<K, V> isTransient(boolean isTransient);
@Override
MapLane<K, V> observe(Object observer);
@Override
MapLane<K, V> unobserve(Object observer);
@Override
MapLane<K, V> willUpdate(WillUpdateKey<K, V> willUpdate);
@Override
MapLane<K, V> didUpdate(DidUpdateKey<K, V> didUpdate);
@Override
MapLane<K, V> willRemove(WillRemoveKey<K> willRemove);
@Override
MapLane<K, V> didRemove(DidRemoveKey<K, V> didRemove);
@Override
MapLane<K, V> willDrop(WillDrop willDrop);
@Override
MapLane<K, V> didDrop(DidDrop didDrop);
@Override
MapLane<K, V> willTake(WillTake willTake);
@Override
MapLane<K, V> didTake(DidTake didTake);
@Override
MapLane<K, V> willClear(WillClear willClear);
@Override
MapLane<K, V> didClear(DidClear didClear);
@Override
MapLane<K, V> willCommand(WillCommand willCommand);
@Override
MapLane<K, V> didCommand(DidCommand didCommand);
@Override
MapLane<K, V> willUplink(WillUplink willUplink);
@Override
MapLane<K, V> didUplink(DidUplink didUplink);
@Override
MapLane<K, V> willEnter(WillEnter willEnter);
@Override
MapLane<K, V> didEnter(DidEnter didEnter);
@Override
MapLane<K, V> willLeave(WillLeave willLeave);
@Override
MapLane<K, V> didLeave(DidLeave didLeave);
OrderedMap<K, V> snapshot();
@Override
Cursor<K> keyIterator();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/SpatialLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import swim.api.warp.WarpLane;
import swim.api.warp.function.DidCommand;
import swim.api.warp.function.DidEnter;
import swim.api.warp.function.DidLeave;
import swim.api.warp.function.DidUplink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillEnter;
import swim.api.warp.function.WillLeave;
import swim.api.warp.function.WillUplink;
import swim.observable.ObservableSpatialMap;
import swim.observable.function.DidClear;
import swim.observable.function.DidMoveShape;
import swim.observable.function.DidRemoveShape;
import swim.observable.function.DidUpdateShape;
import swim.observable.function.WillClear;
import swim.observable.function.WillMoveShape;
import swim.observable.function.WillRemoveShape;
import swim.observable.function.WillUpdateShape;
import swim.spatial.SpatialMap;
import swim.structure.Form;
public interface SpatialLane<K, S, V> extends WarpLane, ObservableSpatialMap<K, S, V> {
Form<K> keyForm();
<K2> SpatialLane<K2, S, V> keyForm(Form<K2> keyForm);
<K2> SpatialLane<K2, S, V> keyClass(Class<K2> keyClass);
Form<V> valueForm();
<V2> SpatialLane<K, S, V2> valueForm(Form<V2> valueForm);
<V2> SpatialLane<K, S, V2> valueClass(Class<V2> valueClass);
boolean isResident();
SpatialLane<K, S, V> isResident(boolean isResident);
boolean isTransient();
SpatialLane<K, S, V> isTransient(boolean isTransient);
@Override
SpatialLane<K, S, V> observe(Object observer);
@Override
SpatialLane<K, S, V> unobserve(Object observer);
@Override
SpatialLane<K, S, V> willUpdate(WillUpdateShape<K, S, V> willUpdate);
@Override
SpatialLane<K, S, V> didUpdate(DidUpdateShape<K, S, V> didUpdate);
@Override
SpatialLane<K, S, V> willMove(WillMoveShape<K, S, V> willMove);
@Override
SpatialLane<K, S, V> didMove(DidMoveShape<K, S, V> didMove);
@Override
SpatialLane<K, S, V> willRemove(WillRemoveShape<K, S> willRemove);
@Override
SpatialLane<K, S, V> didRemove(DidRemoveShape<K, S, V> didRemove);
@Override
SpatialLane<K, S, V> willClear(WillClear willClear);
@Override
SpatialLane<K, S, V> didClear(DidClear didClear);
@Override
SpatialLane<K, S, V> willCommand(WillCommand willCommand);
@Override
SpatialLane<K, S, V> didCommand(DidCommand didCommand);
@Override
SpatialLane<K, S, V> willUplink(WillUplink willUplink);
@Override
SpatialLane<K, S, V> didUplink(DidUplink didUplink);
@Override
SpatialLane<K, S, V> willEnter(WillEnter willEnter);
@Override
SpatialLane<K, S, V> didEnter(DidEnter didEnter);
@Override
SpatialLane<K, S, V> willLeave(WillLeave willLeave);
@Override
SpatialLane<K, S, V> didLeave(DidLeave didLeave);
SpatialMap<K, S, V> snapshot();
}
|
0 | java-sources/ai/swim/swim-api/3.10.0/swim/api | java-sources/ai/swim/swim-api/3.10.0/swim/api/lane/SupplyLane.java | // Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package swim.api.lane;
import swim.api.warp.WarpLane;
import swim.api.warp.function.DidCommand;
import swim.api.warp.function.DidEnter;
import swim.api.warp.function.DidLeave;
import swim.api.warp.function.DidUplink;
import swim.api.warp.function.WillCommand;
import swim.api.warp.function.WillEnter;
import swim.api.warp.function.WillLeave;
import swim.api.warp.function.WillUplink;
import swim.structure.Form;
public interface SupplyLane<V> extends WarpLane {
Form<V> valueForm();
<V2> SupplyLane<V2> valueForm(Form<V2> valueForm);
<V2> SupplyLane<V2> valueClass(Class<V2> valueClass);
@Override
SupplyLane<V> observe(Object observer);
@Override
SupplyLane<V> unobserve(Object observer);
@Override
SupplyLane<V> willCommand(WillCommand willCommand);
@Override
SupplyLane<V> didCommand(DidCommand didCommand);
@Override
SupplyLane<V> willUplink(WillUplink willUplink);
@Override
SupplyLane<V> didUplink(DidUplink didUplink);
@Override
SupplyLane<V> willEnter(WillEnter willEnter);
@Override
SupplyLane<V> didEnter(DidEnter didEnter);
@Override
SupplyLane<V> willLeave(WillLeave willLeave);
@Override
SupplyLane<V> didLeave(DidLeave didLeave);
void push(V value);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.