Search in sources :

Example 1 with RemoteApiInstaller

use of com.google.appengine.tools.remoteapi.RemoteApiInstaller in project pratilipi by Pratilipi.

the class DataStoreUtil method main.

public static void main(String... args) throws IOException, UnexpectedServerException, InterruptedException, ParseException {
    RemoteApiOptions options = new RemoteApiOptions().server("m.gamma.pratilipi.com", 80).useServiceAccountCredential("prod-pratilipi@appspot.gserviceaccount.com", "PrivateKey.p12").remoteApiPath("/remote_api");
    RemoteApiInstaller installer = new RemoteApiInstaller();
    installer.install(options);
    ObjectifyService.begin();
    Memcache memcache = DataAccessorFactory.getL2CacheAccessor();
    GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
    DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
    SearchAccessor searchAccessor = DataAccessorFactory.getSearchAccessor();
    BlobAccessor blobAccessor = DataAccessorFactory.getBlobAccessor();
    DocAccessor docAccessor = DataAccessorFactory.getDocAccessor();
    // START
    // END
    installer.uninstall();
}
Also used : RemoteApiInstaller(com.google.appengine.tools.remoteapi.RemoteApiInstaller) SearchAccessor(com.pratilipi.data.SearchAccessor) GcsService(com.google.appengine.tools.cloudstorage.GcsService) DataAccessor(com.pratilipi.data.DataAccessor) DocAccessor(com.pratilipi.data.DocAccessor) RemoteApiOptions(com.google.appengine.tools.remoteapi.RemoteApiOptions) BlobAccessor(com.pratilipi.data.BlobAccessor) Memcache(com.pratilipi.data.Memcache)

Example 2 with RemoteApiInstaller

use of com.google.appengine.tools.remoteapi.RemoteApiInstaller in project java-docs-samples by GoogleCloudPlatform.

the class RemoteApiExample method main.

public static void main(String[] args) throws IOException {
    String serverString = args[0];
    RemoteApiOptions options;
    if (serverString.equals("localhost")) {
        options = new RemoteApiOptions().server(serverString, 8080).useDevelopmentServerCredential();
    } else {
        options = new RemoteApiOptions().server(serverString, 443).useApplicationDefaultCredential();
    }
    RemoteApiInstaller installer = new RemoteApiInstaller();
    installer.install(options);
    try {
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        System.out.println("Key of new entity is " + ds.put(new Entity("Hello Remote API!")));
    } finally {
        installer.uninstall();
    }
}
Also used : RemoteApiInstaller(com.google.appengine.tools.remoteapi.RemoteApiInstaller) Entity(com.google.appengine.api.datastore.Entity) DatastoreService(com.google.appengine.api.datastore.DatastoreService) RemoteApiOptions(com.google.appengine.tools.remoteapi.RemoteApiOptions)

Example 3 with RemoteApiInstaller

use of com.google.appengine.tools.remoteapi.RemoteApiInstaller in project teammates by TEAMMATES.

the class RemoteApiClient method doOperationRemotely.

protected void doOperationRemotely() throws IOException {
    String appUrl = TestProperties.TEAMMATES_URL.replaceAll("^https?://", "");
    String appDomain = appUrl.split(":")[0];
    int appPort = appUrl.contains(":") ? Integer.parseInt(appUrl.split(":")[1]) : 443;
    System.out.println("--- Starting remote operation ---");
    System.out.println("Going to connect to:" + appDomain + ":" + appPort);
    RemoteApiOptions options = new RemoteApiOptions().server(appDomain, appPort);
    if (TestProperties.isDevServer()) {
        // Dev Server doesn't require credential.
        options.useDevelopmentServerCredential();
    } else {
        // Your Google Cloud SDK needs to be authenticated for Application Default Credentials
        // in order to run any script in production server.
        // Refer to https://developers.google.com/identity/protocols/application-default-credentials.
        options.useApplicationDefaultCredential();
    }
    RemoteApiInstaller installer = new RemoteApiInstaller();
    installer.install(options);
    OfyHelper.registerEntityClasses();
    Closeable objectifySession = ObjectifyService.begin();
    try {
        doOperation();
    } finally {
        objectifySession.close();
        installer.uninstall();
    }
    System.out.println("--- Remote operation completed ---");
}
Also used : RemoteApiInstaller(com.google.appengine.tools.remoteapi.RemoteApiInstaller) Closeable(com.googlecode.objectify.util.Closeable) RemoteApiOptions(com.google.appengine.tools.remoteapi.RemoteApiOptions)

Example 4 with RemoteApiInstaller

use of com.google.appengine.tools.remoteapi.RemoteApiInstaller in project Cached-Datastore by Emperorlou.

the class CachedDatastoreService method getMC.

public MemcacheService getMC() {
    if (mc != null)
        return mc;
    if (isUsingRemoteAPI()) {
        try {
            // Properties p = new Properties();
            // InputStream in = new FileInputStream("C:\\Universe (Non Repo)\\MySpacewarConfig\\db.properties");
            // p.load(in);
            // in.close();
            RemoteApiInstaller installer = new RemoteApiInstaller();
            installer.install(options);
        } catch (IllegalStateException ise) {
        // Ignore. Remote API is probably already installed
        } catch (Exception e) {
            // Ok fine, no remote API
            disableRemoteAPI = true;
            Logger.getLogger(getClass().toString()).log(Level.WARNING, "Failed to connect to remote API", e);
        }
    }
    mc = MemcacheServiceFactory.getMemcacheService();
    return mc;
}
Also used : RemoteApiInstaller(com.google.appengine.tools.remoteapi.RemoteApiInstaller) EntityNotFoundException(com.google.appengine.api.datastore.EntityNotFoundException) InvalidValueException(com.google.appengine.api.memcache.InvalidValueException) ConcurrentModificationException(java.util.ConcurrentModificationException)

Aggregations

RemoteApiInstaller (com.google.appengine.tools.remoteapi.RemoteApiInstaller)4 RemoteApiOptions (com.google.appengine.tools.remoteapi.RemoteApiOptions)3 DatastoreService (com.google.appengine.api.datastore.DatastoreService)1 Entity (com.google.appengine.api.datastore.Entity)1 EntityNotFoundException (com.google.appengine.api.datastore.EntityNotFoundException)1 InvalidValueException (com.google.appengine.api.memcache.InvalidValueException)1 GcsService (com.google.appengine.tools.cloudstorage.GcsService)1 Closeable (com.googlecode.objectify.util.Closeable)1 BlobAccessor (com.pratilipi.data.BlobAccessor)1 DataAccessor (com.pratilipi.data.DataAccessor)1 DocAccessor (com.pratilipi.data.DocAccessor)1 Memcache (com.pratilipi.data.Memcache)1 SearchAccessor (com.pratilipi.data.SearchAccessor)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1