Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
java: [ 11, 13, 15, 16 ]
env:
GOVER: 1.15.0
GOVER: 1.17.7
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
Expand All @@ -29,7 +29,7 @@ jobs:
DAPR_RUNTIME_VER: 1.6.0-rc.2
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.6.0-rc.1/install/install.sh
DAPR_CLI_REF:
DAPR_REF:
DAPR_REF: 5a307f3deaa1b322f7945179adad0403de80eb7e
steps:
- uses: actions/checkout@v3
- name: Set up OpenJDK ${{ env.JDK_VER }}
Expand Down Expand Up @@ -91,6 +91,10 @@ jobs:
run: |
docker-compose -f ./sdk-tests/deploy/local-test-vault.yml up -d
docker ps
- name: Install Local mongo database using docker-compose
run: |
docker-compose -f ./sdk-tests/deploy/local-test-mongo.yml up -d
docker ps
- name: Clean up files
run: mvn clean
- name: Build sdk
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
matrix:
java: [ 11, 13, 15, 16 ]
env:
GOVER: 1.15.0
GOVER: 1.17.7
GOOS: linux
GOARCH: amd64
GOPROXY: https://proxy.golang.org
Expand All @@ -40,7 +40,7 @@ jobs:
DAPR_RUNTIME_VER: 1.6.0-rc.2
DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.6.0-rc.1/install/install.sh
DAPR_CLI_REF:
DAPR_REF:
DAPR_REF: 5a307f3deaa1b322f7945179adad0403de80eb7e
steps:
- uses: actions/checkout@v3
- name: Set up OpenJDK ${{ env.JDK_VER }}
Expand Down Expand Up @@ -108,6 +108,10 @@ jobs:
sudo apt-get install vault
# Verify vault is installed
vault -h
- name: Install Local mongo database using docker-compose
run: |
docker-compose -f ./sdk-tests/deploy/local-test-mongo.yml up -d
docker ps
- name: Clean up files
run: mvn clean
- name: Build sdk
Expand Down Expand Up @@ -153,4 +157,8 @@ jobs:
- name: Validate Configuration API example
working-directory: ./examples
run: |
mm.py ./src/main/java/io/dapr/examples/configuration/grpc/README.md
mm.py ./src/main/java/io/dapr/examples/configuration/grpc/README.md
- name: Validate query state HTTP example
working-directory: ./examples
run: |
mm.py ./src/main/java/io/dapr/examples/querystate/README.md
73 changes: 73 additions & 0 deletions daprdocs/content/en/java-sdk-docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ public interface DemoActor {

### Get & Subscribe to application configurations

> Note this is a preview API and thus will only be accessible via the DaprPreviewClient interface and not the normal DaprClient interface

```java
import io.dapr.client.DaprClientBuilder;
import io.dapr.client.DaprPreviewClient;
Expand All @@ -267,5 +269,76 @@ try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient())
- For a full list of configuration operations visit [How-To: Manage configuration from a store]({{< ref howto-manage-configuration.md >}}).
- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/configuration) for code samples and instructions to try out different configuration operations.

### Query saved state

> Note this is a preview API and thus will only be accessible via the DaprPreviewClient interface and not the normal DaprClient interface

```java
import io.dapr.client.DaprClient;
import io.dapr.client.DaprClientBuilder;
import io.dapr.client.DaprPreviewClient;
import io.dapr.client.domain.QueryStateItem;
import io.dapr.client.domain.QueryStateRequest;
import io.dapr.client.domain.QueryStateResponse;
import io.dapr.client.domain.query.Query;
import io.dapr.client.domain.query.Sorting;
import io.dapr.client.domain.query.filters.EqFilter;

try (DaprClient client = builder.build(); DaprPreviewClient previewClient = builder.buildPreviewClient()) {
String searchVal = args.length == 0 ? "searchValue" : args[0];

// Create JSON data
Listing first = new Listing();
first.setPropertyType("apartment");
first.setId("1000");
...
Listing second = new Listing();
second.setPropertyType("row-house");
second.setId("1002");
...
Listing third = new Listing();
third.setPropertyType("apartment");
third.setId("1003");
...
Listing fourth = new Listing();
fourth.setPropertyType("apartment");
fourth.setId("1001");
...
Map<String, String> meta = new HashMap<>();
meta.put("contentType", "application/json");

// Save state
SaveStateRequest request = new SaveStateRequest(STATE_STORE_NAME).setStates(
new State<>("1", first, null, meta, null),
new State<>("2", second, null, meta, null),
new State<>("3", third, null, meta, null),
new State<>("4", fourth, null, meta, null)
);
client.saveBulkState(request).block();


// Create query and query state request

Query query = new Query()
.setFilter(new EqFilter<>("propertyType", "apartment"))
.setSort(Arrays.asList(new Sorting("id", Sorting.Order.DESC)));
QueryStateRequest request = new QueryStateRequest(STATE_STORE_NAME)
.setQuery(query);

// Use preview client to call query state API
QueryStateResponse<MyData> result = previewClient.queryState(request, MyData.class).block();

// View Query state response
System.out.println("Found " + result.getResults().size() + " items.");
for (QueryStateItem<Listing> item : result.getResults()) {
System.out.println("Key: " + item.getKey());
System.out.println("Data: " + item.getValue());
}
}

```
- For a full list of configuration operations visit [How-To: Query state]({{< ref howto-state-query-api.md >}}).
- Visit [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/querystate) for complete code sample.

## Related links
- [Java SDK examples](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples)
14 changes: 14 additions & 0 deletions examples/components/state/mongo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: mongo-statestore
spec:
type: state.mongodb
version: v1
metadata:
- name: host
value: localhost:27017
- name: databaseName
value: local
- name: collectionName
value: propertyCollection
4 changes: 2 additions & 2 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.4</version>
Comment thread
mukundansundar marked this conversation as resolved.
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -130,7 +130,7 @@
<plugin>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<version>3.10.1</version>
<version>3.11.4</version>
Comment thread
mukundansundar marked this conversation as resolved.
<executions>
<execution>
<phase>generate-sources</phase>
Expand Down
98 changes: 98 additions & 0 deletions examples/src/main/java/io/dapr/examples/querystate/Listing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2021 The Dapr Authors
* 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 io.dapr.examples.querystate;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Objects;

public class Listing {

@JsonProperty
private String propertyType;

@JsonProperty
private String id;

@JsonProperty
private String city;

@JsonProperty
private String state;

public Listing() {
}

public String getPropertyType() {
return propertyType;
}

public void setPropertyType(String propertyType) {
this.propertyType = propertyType;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

public String getState() {
return state;
}

public void setState(String state) {
this.state = state;
}

@Override
public String toString() {
return "Listing{"
+ "propertyType='" + propertyType + '\''
+ ", id=" + id
+ ", city='" + city + '\''
+ ", state='" + state + '\''
+ '}';
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Listing listing = (Listing) o;
return id == listing.id
&& propertyType.equals(listing.propertyType)
&& Objects.equals(city, listing.city)
&& Objects.equals(state, listing.state);
}

@Override
public int hashCode() {
return Objects.hash(propertyType, id, city, state);
}
}
Loading