Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
733584d
WIP: bigtable emulator
igorbernstein2 Oct 19, 2018
471f166
Tests & fixes
igorbernstein2 Oct 19, 2018
d84207f
Merge remote-tracking branch 'origin/master' into bigtable-emulator
igorbernstein2 Oct 19, 2018
51c61c8
visibility tweaks
igorbernstein2 Oct 19, 2018
c21a61e
fixes
igorbernstein2 Oct 31, 2018
b0b122d
Merge remote-tracking branch 'origin/master' into bigtable-emulator
igorbernstein2 Oct 31, 2018
a294c5a
readme + bom
igorbernstein2 Oct 31, 2018
5ef9eca
more readme
igorbernstein2 Oct 31, 2018
ee25573
Merge remote-tracking branch 'origin/master' into bigtable-emulator
igorbernstein2 Oct 31, 2018
5b5f708
Merge branch 'master' into bigtable-emulator
igorbernstein2 Nov 1, 2018
52e211b
create tmp manifest file in same dir as dest to avoid issues with cro…
igorbernstein2 Nov 1, 2018
558c78c
Merge branch 'bigtable-emulator' of github.com:igorbernstein2/google-…
igorbernstein2 Nov 1, 2018
870d3bb
Revert "create tmp manifest file in same dir as dest to avoid issues …
igorbernstein2 Nov 1, 2018
2c7b08f
Fix cross filesystem issues
igorbernstein2 Nov 1, 2018
fd2185e
java 7 fixes
igorbernstein2 Nov 2, 2018
fba8f50
Merge branch 'master' of github.com:GoogleCloudPlatform/google-cloud-…
igorbernstein2 Nov 2, 2018
368ce60
fix bom as well
igorbernstein2 Nov 2, 2018
42ee7e3
fix readme
igorbernstein2 Nov 2, 2018
7615628
still fixing java 7 issues
igorbernstein2 Nov 2, 2018
b9f8ba5
clean up
igorbernstein2 Nov 2, 2018
949b8c5
oops
igorbernstein2 Nov 2, 2018
5ee1ddb
fix windows build
igorbernstein2 Nov 6, 2018
b14326e
Merge branch 'master' of github.com:GoogleCloudPlatform/google-cloud-…
igorbernstein2 Nov 6, 2018
2ec37d8
Minor dep tweaks
igorbernstein2 Nov 6, 2018
1afa15a
tweaks
igorbernstein2 Nov 6, 2018
a9e7ae3
tweaks
igorbernstein2 Nov 6, 2018
2fbde43
Merge branch 'bigtable-emulator' of github.com:igorbernstein2/google-…
igorbernstein2 Nov 6, 2018
65f4c80
Merge branch 'master' of github.com:GoogleCloudPlatform/google-cloud-…
igorbernstein2 Nov 8, 2018
31769e9
tweak
igorbernstein2 Nov 8, 2018
9daec05
license
igorbernstein2 Nov 8, 2018
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
Prev Previous commit
Next Next commit
fix windows build
  • Loading branch information
igorbernstein2 committed Nov 6, 2018
commit 5ee1ddba7b5c5bccec5973e1a9a09ad04064d4cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
import io.grpc.ManagedChannelBuilder;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URL;
import java.nio.file.Path;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -62,17 +62,18 @@ public class Emulator {
* creating it.
*/
public static Emulator createBundled() throws IOException {
String resourcePath = String.format(
"/gcloud/bigtable-%s/platform/bigtable-emulator/cbtemulator", getPlatform());

URL packagedEmulator = Emulator.class.getResource(resourcePath);
String resourcePath = getBundledResourcePath();

File tmpEmulator = File.createTempFile("cbtemulator", "");
tmpEmulator.deleteOnExit();

try (InputStream is = packagedEmulator.openStream();
try (InputStream is = Emulator.class.getResourceAsStream(resourcePath);
FileOutputStream os = new FileOutputStream(tmpEmulator)) {

if (is == null) {
throw new FileNotFoundException("Failed to find the bundled emulator binary: " + resourcePath);
}

byte[] buff = new byte[2048];
int length;

Expand Down Expand Up @@ -187,14 +188,16 @@ public synchronized ManagedChannel getAdminChannel() {
// <editor-fold desc="Helpers">

/** Gets the current platform, which will be used to select the appropriate emulator binary. */
private static String getPlatform() {
private static String getBundledResourcePath() {
String unformattedOs = System.getProperty("os.name", "unknown").toLowerCase(Locale.ENGLISH);
String os;
String suffix = "";

if (unformattedOs.contains("mac") || unformattedOs.contains("darwin")) {
os = "darwin";
} else if (unformattedOs.contains("win")) {
os = "windows";
suffix = ".exe";
} else if (unformattedOs.contains("linux")) {
os = "linux";
} else {
Expand All @@ -217,7 +220,8 @@ private static String getPlatform() {
throw new UnsupportedOperationException("Unsupported architecture: " + unformattedArch);
}

return os + "-" + arch;
return String.format(
"/gcloud/bigtable-%s-%s/platform/bigtable-emulator/cbtemulator%s", os, arch, suffix);
}

/** Gets a random open port number. */
Expand Down