congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
LocalRouteStore
Code IndexAdd Tabnine to your IDE (free)

How to use
LocalRouteStore
in
co.cask.cdap.route.store

Best Java code snippets using co.cask.cdap.route.store.LocalRouteStore (Showing top 7 results out of 315)

origin: cdapio/cdap

@Override
public void store(final ProgramId serviceId, final RouteConfig routeConfig) {
 Transactionals.execute(transactional, context -> {
  getRouteTable(context).write(ServiceDiscoverable.getName(serviceId), GSON.toJson(routeConfig.getRoutes()));
 });
}
origin: cdapio/cdap

 @Test
 public void testRouteStorage() throws Exception {
  RouteStore routeStore = new LocalRouteStore(datasetFramework, new InMemoryTxSystemClient(txManager));

  ApplicationId appId = new ApplicationId("n1", "a1");
  ProgramId service1 = appId.service("s1");
  RouteConfig routeConfig = new RouteConfig(ImmutableMap.of("v1", 100));
  routeStore.store(service1, routeConfig);
  Assert.assertEquals(routeConfig.getRoutes(), routeStore.fetch(service1).getRoutes());
  routeStore.delete(service1);
  Assert.assertNotNull(routeStore.fetch(service1));

  try {
   routeStore.delete(service1);
   Assert.fail("Config should have been deleted and thus a NotFoundException must have been thrown.");
  } catch (NotFoundException e) {
   // expected
  }
 }
}
origin: co.cask.cdap/cdap-app-fabric

@Override
public void store(final ProgramId serviceId, final RouteConfig routeConfig) {
 Transactionals.execute(transactional, context -> {
  getRouteTable(context).write(ServiceDiscoverable.getName(serviceId), GSON.toJson(routeConfig.getRoutes()));
 });
}
origin: cdapio/cdap

@Override
public RouteConfig fetch(final ProgramId serviceId) {
 return Transactionals.execute(transactional, context -> {
  byte[] value = getRouteTable(context).read(ServiceDiscoverable.getName(serviceId));
  if (value == null) {
   return new RouteConfig(Collections.emptyMap());
  }
  return new RouteConfig(GSON.fromJson(Bytes.toString(value), MAP_STRING_INTEGER_TYPE));
 });
}
origin: co.cask.cdap/cdap-app-fabric

@Override
public RouteConfig fetch(final ProgramId serviceId) {
 return Transactionals.execute(transactional, context -> {
  byte[] value = getRouteTable(context).read(ServiceDiscoverable.getName(serviceId));
  if (value == null) {
   return new RouteConfig(Collections.emptyMap());
  }
  return new RouteConfig(GSON.fromJson(Bytes.toString(value), MAP_STRING_INTEGER_TYPE));
 });
}
origin: cdapio/cdap

@Override
public void delete(final ProgramId serviceId) throws NotFoundException {
 Transactionals.execute(transactional, context -> {
  byte[] key = Bytes.toBytes(ServiceDiscoverable.getName(serviceId));
  KeyValueTable kvTable = getRouteTable(context);
  if (kvTable.read(key) == null) {
   throw new NotFoundException(String.format("Route Config for Service %s was not found.", serviceId));
  }
  kvTable.delete(key);
 }, NotFoundException.class);
}
origin: co.cask.cdap/cdap-app-fabric

@Override
public void delete(final ProgramId serviceId) throws NotFoundException {
 Transactionals.execute(transactional, context -> {
  byte[] key = Bytes.toBytes(ServiceDiscoverable.getName(serviceId));
  KeyValueTable kvTable = getRouteTable(context);
  if (kvTable.read(key) == null) {
   throw new NotFoundException(String.format("Route Config for Service %s was not found.", serviceId));
  }
  kvTable.delete(key);
 }, NotFoundException.class);
}
co.cask.cdap.route.storeLocalRouteStore

Javadoc

RouteStore where the routes are stored in a table for persistence. This is intended for use in SDK mode where performance is not a big issue but we still need persistence of configuration routes across restarts.

Most used methods

  • <init>
  • getRouteTable

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • compareTo (BigDecimal)
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Reference (javax.naming)
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now