use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project che by eclipse.
the class PomReconcilerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
when(projectRegistryProvider.get()).thenReturn(projectRegistry);
MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
MavenTerminal terminal = new MavenTerminal() {
@Override
public void print(int level, String message, Throwable throwable) throws RemoteException {
System.out.println(message);
if (throwable != null) {
throwable.printStackTrace();
}
}
};
File localRepository = new File(new File("target/localRepo").getAbsolutePath());
localRepository.mkdirs();
mavenServerManager.setLocalRepository(localRepository);
MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
projectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
ClasspathManager classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, projectManager, terminal, mavenNotifier);
mavenWorkspace = new MavenWorkspace(projectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {
@Override
public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
}
@Override
public void sendNotification(NotificationMessage message) {
System.out.println(message.toString());
}
@Override
public void send(JsonObject object, MessageType type) {
}
}, classpathManager, eventService, new EclipseWorkspaceProvider());
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project che by eclipse.
the class WorkspaceTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
when(projectRegistryProvider.get()).thenReturn(projectRegistry);
MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
MavenTerminal terminal = new MavenTerminal() {
@Override
public void print(int level, String message, Throwable throwable) throws RemoteException {
System.out.println(message);
if (throwable != null) {
throwable.printStackTrace();
}
}
};
MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {
@Override
public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
}
@Override
public void sendNotification(NotificationMessage message) {
System.out.println(message.toString());
}
@Override
public void send(JsonObject object, MessageType type) {
}
}, new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier), eventService, new EclipseWorkspaceProvider());
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project che by eclipse.
the class ClasspathManagerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
when(projectRegistryProvider.get()).thenReturn(projectRegistry);
MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
MavenTerminal terminal = (level, message, throwable) -> {
System.out.println(message);
if (throwable != null) {
throwable.printStackTrace();
}
};
localRepository = new File(new File("target/localRepo").getAbsolutePath());
localRepository.mkdirs();
mavenServerManager.setLocalRepository(localRepository);
MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier);
mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {
@Override
public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
}
@Override
public void sendNotification(NotificationMessage message) {
System.out.println(message.toString());
}
@Override
public void send(JsonObject object, MessageType type) {
}
}, classpathManager, eventService, new EclipseWorkspaceProvider());
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project weave by continuuity.
the class YarnWeaveRunnerService method getApplicationId.
/**
* Decodes application ID stored inside the node data.
* @param nodeData The node data to decode from. If it is {@code null}, this method would return {@code null}.
* @return The ApplicationId or {@code null} if failed to decode.
*/
private ApplicationId getApplicationId(NodeData nodeData) {
byte[] data = nodeData == null ? null : nodeData.getData();
if (data == null) {
return null;
}
Gson gson = new Gson();
JsonElement json = gson.fromJson(new String(data, Charsets.UTF_8), JsonElement.class);
if (!json.isJsonObject()) {
LOG.warn("Unable to decode live data node.");
return null;
}
JsonObject jsonObj = json.getAsJsonObject();
json = jsonObj.get("data");
if (!json.isJsonObject()) {
LOG.warn("Property data not found in live data node.");
return null;
}
try {
ApplicationMasterLiveNodeData amLiveNode = gson.fromJson(json, ApplicationMasterLiveNodeData.class);
return YarnUtils.createApplicationId(amLiveNode.getAppIdClusterTime(), amLiveNode.getAppId());
} catch (Exception e) {
LOG.warn("Failed to decode application live node data.", e);
return null;
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.gson.JsonObject in project buck by facebook.
the class ChromeTraceParser method parse.
/**
* Parses a Chrome trace and stops parsing once all of the specified matchers have been
* satisfied. This method parses only one Chrome trace event at a time, which avoids loading the
* entire trace into memory.
* @param pathToTrace is a relative path [to the ProjectFilesystem] to a Chrome trace in the
* "JSON Array Format."
* @param chromeTraceEventMatchers set of matchers this invocation of {@code parse()} is trying to
* satisfy. Once a matcher finds a match, it will not consider any other events in the trace.
* @return a {@code Map} where every matcher that found a match will have an entry whose key is
* the matcher and whose value is the one returned by
* {@link ChromeTraceEventMatcher#test(JsonObject, String)} without the {@link Optional}
* wrapper.
*/
public Map<ChromeTraceEventMatcher<?>, Object> parse(Path pathToTrace, Set<ChromeTraceEventMatcher<?>> chromeTraceEventMatchers) throws IOException {
Set<ChromeTraceEventMatcher<?>> unmatchedMatchers = new HashSet<>(chromeTraceEventMatchers);
Preconditions.checkArgument(!unmatchedMatchers.isEmpty(), "Must specify at least one matcher");
Map<ChromeTraceEventMatcher<?>, Object> results = new HashMap<>();
try (InputStream input = projectFilesystem.newFileInputStream(pathToTrace);
JsonReader jsonReader = new JsonReader(new InputStreamReader(input))) {
jsonReader.beginArray();
Gson gson = new Gson();
featureSearch: while (true) {
// If END_ARRAY is the next token, then there are no more elements in the array.
if (jsonReader.peek().equals(JsonToken.END_ARRAY)) {
break;
}
// Verify and extract the name property before invoking any of the matchers.
JsonElement eventEl = gson.fromJson(jsonReader, JsonElement.class);
JsonObject event = eventEl.getAsJsonObject();
JsonElement nameEl = event.get("name");
if (nameEl == null || !nameEl.isJsonPrimitive()) {
continue;
}
String name = nameEl.getAsString();
// Prefer Iterator to Iterable+foreach so we can use remove().
for (Iterator<ChromeTraceEventMatcher<?>> iter = unmatchedMatchers.iterator(); iter.hasNext(); ) {
ChromeTraceEventMatcher<?> chromeTraceEventMatcher = iter.next();
Optional<?> result = chromeTraceEventMatcher.test(event, name);
if (result.isPresent()) {
iter.remove();
results.put(chromeTraceEventMatcher, result.get());
if (unmatchedMatchers.isEmpty()) {
break featureSearch;
}
}
}
}
}
// We could throw if !unmatchedMatchers.isEmpty(), but that might be overbearing.
return results;
}
Aggregations