Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

see https://github.com/mhansonp/geode/tree/BlogCode

What you are going to need to get your REST command working

...

?

OperationController this is what specifies the endpoints and the security to allow access to the thing you want to do. The main thing the OperationController does is map the REST commands to function calls. For this example our class name is BlogCodeOperationController. Using the endpoint and command type (POST or GET) it tells what command is being executed. There are three commands that necessary to be compliant the the ClusterManagementOperation POST, GET, and List. Please also note that the security settings are custom to the command type... Please see https://cwiki.apache.org/confluence/display/GEODE/Finer+grained+security to understand where your code might sit in terms of security.

...

Info
Please keep in mind that so much of this is just boiler plate to connect all the dots. The serialization support, in particular, is suport super picky.

Content by Label
showLabelsfalse
max5
spacesGEODE
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ("geode","cluster") and type = "page" and space = "GEODE"
labelsGEODE Cluster

...

hiddentrue


Here is the unit test of this code


public class BlogCodeDUnitTest {

@Rule
public ClusterStartupRule cluster = new ClusterStartupRule();

private MemberVM locator;
private List<MemberVM> servers;
private static final int SERVERS_TO_START = 1;

private ClusterManagementService client1;

@Before
public void setup() {
     locator = cluster.startLocatorVM(0, MemberStarterRule::withHttpService);
     servers = new ArrayList<>();
     int locatorPort = locator.getPort();
     IntStream.range(0, SERVERS_TO_START)
       .forEach(i -> servers.add(cluster.startServerVM(i + 1, locatorPort)));

    client1 = new ClusterManagementServiceBuilder()
      .setHost("localhost")
      .setPort(locator.getHttpPort())
      .build();
  }

@After
public void tearDown() {
    client1.close();
  }

@Test
public void testBlogCode() throws ExecutionException, InterruptedException {

    BlogCodeRequest blogCodeRequest = new BlogCodeRequest();

    ClusterManagementOperationResult<BlogCodeRequest, BlogCodeResponse> startResult =
    client1.start(blogCodeRequest);

    assertThat(startResult.isSuccessful()).isTrue();

    ClusterManagementOperationResult<BlogCodeRequest, BlogCodeResponse> endResult =
    client1.getFuture(blogCodeRequest, startResult.getOperationId()).get();

    BlogCodeResponse blogCodeResponse = endResult.getOperationResult();

    assertThat(blogCodeResponse.getSuccess()).isTrue();

    assertThat(blogCodeResponse.getStatusMessage()).isEqualTo("Hello, World!");
  }

}

...