Search in sources :

Example 16 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project AGREE by loonwerks.

the class AgreeASTBuilder method getConnectionStatements.

private List<AgreeOverriddenConnection> getConnectionStatements(EList<SpecStatement> specs) {
    List<AgreeOverriddenConnection> conns = new ArrayList<>();
    for (SpecStatement spec : specs) {
        if (spec instanceof ConnectionStatement) {
            Expr expr = doSwitch(((ConnectionStatement) spec).getExpr());
            Connection conn = (Connection) ((ConnectionStatement) spec).getConn();
            AgreeOverriddenConnection agreeConn = new AgreeOverriddenConnection(new AgreeStatement("", expr, spec), conn);
            conns.add(agreeConn);
        }
    }
    return conns;
}
Also used : EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) ConnectionStatement(com.rockwellcollins.atc.agree.agree.ConnectionStatement) ArrayList(java.util.ArrayList) PortConnection(org.osate.aadl2.PortConnection) Connection(org.osate.aadl2.Connection) SpecStatement(com.rockwellcollins.atc.agree.agree.SpecStatement)

Example 17 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project AGREE by loonwerks.

the class AgreeValidator method checkConnectionStatement.

@Check(CheckType.FAST)
public void checkConnectionStatement(ConnectionStatement conn) {
    Classifier container = conn.getContainingClassifier();
    if (container instanceof ComponentImplementation) {
        NamedElement aadlConn = conn.getConn();
        if (aadlConn == null) {
            return;
        }
        if (!(aadlConn instanceof Connection)) {
            error(conn, "The connection label in the connection statement is not a connection");
            return;
        }
        TypeDef rhsType = (AgreeTypeSystem.infer(conn.getExpr()));
        if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, rhsType)) {
            error(conn, "The expression for the connection statement is of type '" + nameOfTypeDef(rhsType) + "' but must be of type 'bool'");
        }
    } else {
        error(conn, "Connection statements are allowed only in component implementations.");
    }
    warning(conn, "Connection statements are deprecated and will be removed in a future version of AGREE.");
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) Connection(org.osate.aadl2.Connection) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) NamedElement(org.osate.aadl2.NamedElement) Check(org.eclipse.xtext.validation.Check)

Example 18 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project AGREE by loonwerks.

the class AgreeValidator method checkLiftContract.

@Check(CheckType.FAST)
public void checkLiftContract(LiftContractStatement lcst) {
    Classifier comp = lcst.getContainingClassifier();
    if (comp instanceof ComponentImplementation) {
        ComponentType ct = ((ComponentImplementation) comp).getType();
        List<AnnexSubclause> agreeAnnexes = AnnexUtil.getAllAnnexSubclauses(ct, AgreePackage.eINSTANCE.getAgreeContractSubclause());
        if (agreeAnnexes.size() > 0) {
            error(lcst, "'lift contract;' statement is not allowed in component implementation whose type has an AGREE annex.");
        }
        List<Subcomponent> subcomps = ((ComponentImplementation) comp).getAllSubcomponents();
        if (subcomps.size() == 1) {
            Subcomponent subcomp = subcomps.get(0);
            Classifier subCls = subcomp.getClassifier();
            ComponentType subCt = null;
            if (subCls instanceof ComponentImplementation) {
                subCt = ((ComponentImplementation) subCls).getType();
            } else if (subCls instanceof ComponentType) {
                subCt = (ComponentType) subCls;
            } else {
                throw new RuntimeException();
            }
            {
                Set<String> usedParentInPorts = new HashSet<>();
                Set<String> usedParentOutPorts = new HashSet<>();
                Set<String> usedChildInPorts = new HashSet<>();
                Set<String> usedChildOutPorts = new HashSet<>();
                EList<Classifier> ctPlusAllExtended = ct.getSelfPlusAllExtended();
                EList<Classifier> subCtPlusAllExtended = subCt.getSelfPlusAllExtended();
                for (Connection conn : ((ComponentImplementation) comp).getAllConnections()) {
                    {
                        NamedElement sourceNe = conn.getSource().getConnectionEnd();
                        if (subCtPlusAllExtended.contains(sourceNe.getContainingClassifier())) {
                            if (usedChildOutPorts.contains(sourceNe.getName())) {
                                error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection out of same output " + sourceNe.getQualifiedName() + ".");
                            }
                            usedChildOutPorts.add(sourceNe.getName());
                        }
                        if (ctPlusAllExtended.contains(sourceNe.getContainingClassifier())) {
                            if (usedParentInPorts.contains(sourceNe.getName())) {
                                error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection out of same input " + sourceNe.getQualifiedName() + ".");
                            }
                            usedParentInPorts.add(sourceNe.getName());
                        }
                    }
                    {
                        NamedElement destNe = conn.getDestination().getConnectionEnd();
                        if (subCtPlusAllExtended.contains(destNe.getContainingClassifier())) {
                            if (usedChildInPorts.contains(destNe.getName())) {
                                error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection into same input " + destNe.getQualifiedName() + ".");
                            }
                            usedChildInPorts.add(destNe.getName());
                        }
                        if (ctPlusAllExtended.contains(destNe.getContainingClassifier())) {
                            if (usedParentOutPorts.contains(destNe.getName())) {
                                error(lcst, "'lift contract;' statement is not allowed in component implementation whith more than one connection into same output " + destNe.getQualifiedName() + ".");
                            }
                            usedParentOutPorts.add(destNe.getName());
                        }
                    }
                }
                for (Feature feat : comp.getAllFeatures()) {
                    boolean isIn = false;
                    if (feat instanceof DataPort) {
                        isIn = ((DataPort) feat).isIn();
                    } else if (feat instanceof EventDataPort) {
                        isIn = ((EventDataPort) feat).isIn();
                    } else if (feat instanceof EventPort) {
                        isIn = ((EventPort) feat).isIn();
                    }
                    if (isIn) {
                        if (!usedParentInPorts.contains(feat.getName())) {
                            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection from input " + feat.getQualifiedName() + ".");
                        }
                    } else {
                        if (!usedParentOutPorts.contains(feat.getName())) {
                            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection to output " + feat.getQualifiedName() + ".");
                        }
                    }
                }
                for (Feature feat : subCt.getAllFeatures()) {
                    boolean isIn = false;
                    if (feat instanceof DataPort) {
                        isIn = ((DataPort) feat).isIn();
                    } else if (feat instanceof EventDataPort) {
                        isIn = ((EventDataPort) feat).isIn();
                    } else if (feat instanceof EventPort) {
                        isIn = ((EventPort) feat).isIn();
                    }
                    if (isIn) {
                        if (!usedChildInPorts.contains(feat.getName())) {
                            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection into " + feat.getQualifiedName() + ".");
                        }
                    } else {
                        if (!usedChildOutPorts.contains(feat.getName())) {
                            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout connection out of " + feat.getQualifiedName() + ".");
                        }
                    }
                }
            }
        } else {
            error(lcst, "'lift contract;' statement is not allowed in component implementation whithout exactly one subcomponent.");
        }
    } else {
        error(lcst, "'lift contract;' statement is not allowed in component interface.");
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) ComponentType(org.osate.aadl2.ComponentType) Set(java.util.Set) HashSet(java.util.HashSet) Connection(org.osate.aadl2.Connection) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Feature(org.osate.aadl2.Feature) DataPort(org.osate.aadl2.DataPort) EventDataPort(org.osate.aadl2.EventDataPort) EList(org.eclipse.emf.common.util.EList) EventPort(org.osate.aadl2.EventPort) Subcomponent(org.osate.aadl2.Subcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) EventDataPort(org.osate.aadl2.EventDataPort) NamedElement(org.osate.aadl2.NamedElement) AnnexSubclause(org.osate.aadl2.AnnexSubclause) Check(org.eclipse.xtext.validation.Check)

Example 19 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project spring-cloud-square by spring-projects-experimental.

the class TracingOkHttpInterceptor method parseRouteAddress.

private static void parseRouteAddress(Chain chain, Span span) {
    if (span.isNoop()) {
        return;
    }
    Connection connection = chain.connection();
    if (connection == null) {
        return;
    }
    InetSocketAddress socketAddress = connection.route().socketAddress();
    span.remoteIpAndPort(socketAddress.getHostString(), socketAddress.getPort());
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Connection(okhttp3.Connection)

Example 20 with Connection

use of com.google.cloud.bigquery.connection.v1.Connection in project eladmin by lWoHvYe.

the class ScpClientUtil method putFile.

public void putFile(String localFile, String remoteFileName, String remoteTargetDirectory, String mode) {
    Connection conn = new Connection(ip, port);
    File file = new File(localFile);
    if (file.isDirectory()) {
        throw new RuntimeException(localFile + "  is not a file");
    }
    String fileName = file.getName();
    try {
        conn.connect();
        boolean isAuthenticated = conn.authenticateWithPassword(username, password);
        if (!isAuthenticated) {
            System.err.println("authentication failed");
        }
        var client = conn.createSCPClient();
        if ((mode == null) || (mode.length() == 0))
            mode = "0600";
        var scpOutputStream = client.put(StrUtil.isNotEmpty(remoteFileName) ? remoteFileName : fileName, file.length(), remoteTargetDirectory, mode);
        String content = IOUtils.toString(new FileInputStream(file), String.valueOf(StandardCharsets.UTF_8));
        scpOutputStream.write(content.getBytes());
        scpOutputStream.flush();
        scpOutputStream.close();
    } catch (IOException ex) {
        Logger.getLogger(ScpClientUtil.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        conn.close();
    }
}
Also used : Connection(ch.ethz.ssh2.Connection) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

IOException (java.io.IOException)87 Connection (com.trilead.ssh2.Connection)70 Connection (org.ovirt.engine.sdk4.Connection)64 Connection (org.osate.aadl2.Connection)58 Connection (ch.ethz.ssh2.Connection)47 Test (org.junit.Test)35 Session (com.trilead.ssh2.Session)33 Connection (okhttp3.Connection)33 Connection (org.jboss.remoting3.Connection)33 Connection (com.google.cloud.bigquery.connection.v1.Connection)31 InputStream (java.io.InputStream)31 VmsService (org.ovirt.engine.sdk4.services.VmsService)30 Vm (org.ovirt.engine.sdk4.types.Vm)30 Request (okhttp3.Request)23 Response (okhttp3.Response)20 Subcomponent (org.osate.aadl2.Subcomponent)20 ArrayList (java.util.ArrayList)19 FeatureGroupConnection (org.osate.aadl2.FeatureGroupConnection)19 VmService (org.ovirt.engine.sdk4.services.VmService)18 ResponseBody (okhttp3.ResponseBody)17