项目:ios-device-control
文件:IosAppInfo.java
/** Returns the application info read from either an app folder or ipa archive */
public static IosAppInfo readFromPath(Path ipaOrAppPath) throws IOException {
NSObject plistDict;
if (Files.isDirectory(ipaOrAppPath)) {
plistDict = PlistParser.fromPath(ipaOrAppPath.resolve("Info.plist"));
} else {
try (FileSystem ipaFs = FileSystems.newFileSystem(ipaOrAppPath,null)) {
Path appPath =
MoreFiles.listFiles(ipaFs.getPath("Payload"))
.stream()
// Can't use Files.isDirectory,because no entry is a "directory" in a zip.
.filter(e -> e.toString().endsWith(".app/"))
.collect(MoreCollectors.onlyElement());
plistDict = PlistParser.fromPath(appPath.resolve("Info.plist"));
}
}
return readFromPlistDictionary((NSDictionary) plistDict);
}
项目:ios-device-control
文件:SimulatorDeviceHost.java
private static IosModel toModel(String deviceType) throws IOException {
checkArgument(deviceType.matches("[-\\w]*"));
Path profileInfoBasePath =
Paths.get(
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/"
+ "Developer/Library/CoreSimulator/Profiles/DeviceTypes");
Path deviceTypePath =
MoreFiles.listFiles(profileInfoBasePath)
.stream()
// The directory name that matches a given device type is the same as the name from the
// device.plist file,with the hyphens replaced with spaces,hyphens,parentheses or
// periods
.filter(
p -> MoreFiles.getNameWithoutExtension(p).replaceAll("\\W","-").equals(deviceType))
.collect(MoreCollectors.onlyElement());
String rawProductName = MoreFiles.getNameWithoutExtension(deviceTypePath);
String productName = GENERATION_PATTERN.matcher(rawProductName).replaceFirst("$1");
Path profilePath = deviceTypePath.resolve("Contents/Resources/profile.plist");
NSDictionary profileDict = (NSDictionary) PlistParser.fromPath(profilePath);
String identifier = profileDict.get("modelIdentifier").toString();
NSArray supportedArchs = (NSArray) profileDict.get("supportedArchs");
// The supported architecture can either be just i386 or i386 and x86_64. The
// actual architecture will be x86_64 if its supported,or i386 otherwise.
Architecture architecture =
supportedArchs.containsObject(Architecture.X86_64.toString())
? Architecture.X86_64
: Architecture.I386;
return IosModel.builder()
.identifier(identifier)
.productName(productName)
.architecture(architecture)
.build();
}
项目:ios-device-control
文件:SimulatorDeviceImpl.java
private ImmutableSet<IosAppInfo> userApps() throws IOException {
Path appPath =
Paths.get(
System.getProperty("user.home"),"Library/Developer/CoreSimulator/Devices",udid,"data/Containers/Bundle/Application");
if (!Files.exists(appPath)) {
return ImmutableSet.of();
}
try {
return MoreFiles.listFiles(appPath)
.stream()
.map(
p ->
tunnel(
() ->
MoreFiles.listFiles(p)
.stream()
.filter(a -> MoreFiles.getFileExtension(a).equals("app"))
.collect(MoreCollectors.onlyElement())))
.map(a -> tunnel(() -> IosAppInfo.readFromPath(a)))
.collect(toImmutableSet());
} catch (TunnelException e) {
throw e.getCauseAs(IOException.class);
}
}
项目:orchestrator
文件:AbstractMesosDeploymentService.java
protected NodeTemplate getHostNode(DirectedMultigraph<NodeTemplate,RelationshipTemplate> graph,NodeTemplate taskNode) {
return graph
.incomingEdgesOf(taskNode)
.stream()
.filter(
relationship -> HOST_CAPABILITY_NAME.equals(relationship.getTargetedCapabilityName()))
.map(graph::getEdgeSource)
// if more than 1 node is present -> IllegalArgumentException
.collect(MoreCollectors.toOptional())
.orElseThrow(() -> new IllegalArgumentException(
String.format("No hosting node provided for node <%s>",taskNode.getName())));
}
项目:error-prone
文件:TypeParameterShadowing.java
private TypeParameterTree typeParameterInList(
List<? extends TypeParameterTree> typeParameters,TypeVariableSymbol v) {
return typeParameters
.stream()
.filter(t -> t.getName().contentEquals(v.name))
.collect(MoreCollectors.onlyElement());
}
项目:orchestrator
文件:MarathonServiceImpl.java
@Override
public void finalizeDeploy(DeploymentMessage deploymentMessage) {
Deployment deployment = getDeployment(deploymentMessage);
ArchiveRoot ar = toscaService
.prepareTemplate(deployment.getTemplate(),deployment.getParameters());
Map<String,OutputDefinition> outputs = Optional
.ofNullable(ar.getTopology())
.map(Topology::getOutputs)
.orElseGet(HashMap::new);
if (!outputs.isEmpty()) {
String groupId = deployment.getId();
Group group = getMarathonClient(deployment).getGroup(groupId);
Map<String,NodeTemplate> nodes = Optional
.ofNullable(ar.getTopology())
.map(Topology::getNodeTemplates)
.orElseGet(HashMap::new);
DirectedMultigraph<NodeTemplate,RelationshipTemplate> graph =
toscaService.buildNodeGraph(nodes,false);
TopologicalOrderIterator<NodeTemplate,RelationshipTemplate> orderIterator =
new TopologicalOrderIterator<>(graph);
List<NodeTemplate> orderedMarathonApps = CommonUtils
.iteratorToStream(orderIterator)
.filter(node -> toscaService.isOfToscaType(node,ToscaConstants.Nodes.MARATHON))
.collect(Collectors.toList());
MarathonProperties marathonProperties =
marathonClientFactory.getFrameworkProperties(deployment);
RuntimeProperties runtimeProperties = new RuntimeProperties();
for (NodeTemplate marathonNode : orderedMarathonApps) {
runtimeProperties.put(marathonProperties.getLoadBalancerIps(),marathonNode.getName(),"load_balancer_ips");
List<Integer> ports = group
.getApps()
.stream()
.filter(
app -> app.getId().endsWith("/" + marathonNode.getName()))
.collect(MoreCollectors.toOptional())
.map(App::getPorts)
.orElseGet(ArrayList::new);
NodeTemplate hostNode = getHostNode(graph,marathonNode);
for (int i = 0; i < ports.size(); ++i) {
runtimeProperties.put(ports.get(i),hostNode.getName(),"host","publish_ports",String.valueOf(i),"target");
}
}
deployment.setOutputs(indigoInputsPreProcessorService.processOutputs(ar,deployment.getParameters(),runtimeProperties));
}
super.finalizeDeploy(deploymentMessage);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。