Search in sources :

Example 51 with PluginDefineException

use of com.dtstack.taier.pluginapi.exception.PluginDefineException in project Taier by DTStack.

the class PrepareOperator method parseJarFile.

public static JarFileInfo parseJarFile(String sql) {
    Matcher matcher = jarFilePattern.matcher(sql);
    if (!matcher.find()) {
        throw new PluginDefineException("not a addJar operator:" + sql);
    }
    JarFileInfo jarFileInfo = new JarFileInfo();
    jarFileInfo.setJarPath(matcher.group(1));
    if (matcher.groupCount() == 3) {
        jarFileInfo.setMainClass(matcher.group(3));
    }
    return jarFileInfo;
}
Also used : JarFileInfo(com.dtstack.taier.pluginapi.JarFileInfo) Matcher(java.util.regex.Matcher) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException)

Example 52 with PluginDefineException

use of com.dtstack.taier.pluginapi.exception.PluginDefineException in project Taier by DTStack.

the class PrepareOperator method getResourceFileName.

public static String getResourceFileName(String sql) {
    Matcher matcher = resourceFilePattern.matcher(sql);
    if (!matcher.find()) {
        throw new PluginDefineException("Get Resource File Name Error: " + sql);
    }
    String fileName = matcher.group(3);
    if (StringUtils.isBlank(fileName)) {
        fileName = getResourceFile(sql).getName();
    }
    return fileName;
}
Also used : Matcher(java.util.regex.Matcher) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException)

Example 53 with PluginDefineException

use of com.dtstack.taier.pluginapi.exception.PluginDefineException in project Taier by DTStack.

the class SqlPluginInfo method getCoreJarFileName.

private String getCoreJarFileName() {
    String coreJarFileName = null;
    File pluginDir = new File(localSqlPluginDir);
    if (pluginDir.exists() && pluginDir.isDirectory()) {
        File[] jarFiles = pluginDir.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                return name.toLowerCase().startsWith(ConfigConstrant.FLINKSQl_CORE_JAR_PREFIX) && name.toLowerCase().endsWith(".jar");
            }
        });
        if (jarFiles != null && jarFiles.length > 0) {
            coreJarFileName = jarFiles[0].getName();
        }
    }
    if (StringUtils.isEmpty(coreJarFileName)) {
        throw new PluginDefineException("Can not find core jar file in sqlPlugin path: " + localSqlPluginDir);
    }
    return coreJarFileName;
}
Also used : FilenameFilter(java.io.FilenameFilter) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException) File(java.io.File)

Example 54 with PluginDefineException

use of com.dtstack.taier.pluginapi.exception.PluginDefineException in project Taier by DTStack.

the class SyncPluginInfo method getCoreJarFileName.

private String getCoreJarFileName() {
    String coreJarFileName = null;
    File pluginDir = new File(localSyncPluginDir);
    if (pluginDir.exists() && pluginDir.isDirectory()) {
        File[] jarFiles = pluginDir.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                return name.toLowerCase().startsWith(ConfigConstrant.FLINKX_CORE_JAR_PREFIX) && name.toLowerCase().endsWith(".jar");
            }
        });
        if (jarFiles != null && jarFiles.length > 0) {
            coreJarFileName = jarFiles[0].getName();
        }
    }
    if (StringUtils.isEmpty(coreJarFileName)) {
        throw new PluginDefineException("Can not find core jar file in syncPlugin path: " + localSyncPluginDir);
    }
    return coreJarFileName;
}
Also used : FilenameFilter(java.io.FilenameFilter) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException) File(java.io.File)

Example 55 with PluginDefineException

use of com.dtstack.taier.pluginapi.exception.PluginDefineException in project Taier by DTStack.

the class FileUtil method readStreamFromFile.

public static InputStream readStreamFromFile(String filePath, Configuration hadoopConf) throws URISyntaxException, IOException {
    Pair<String, String> pair = parseHdfsUri(filePath);
    if (pair == null) {
        throw new PluginDefineException("can't parse hdfs url from given uriStr:" + filePath);
    }
    String hdfsUri = pair.getLeft();
    String hdfsFilePathStr = pair.getRight();
    URI uri = new URI(hdfsUri);
    FileSystem fs = FileSystem.get(uri, hadoopConf);
    Path hdfsFilePath = new Path(hdfsFilePathStr);
    if (!fs.exists(hdfsFilePath)) {
        throw new RuntimeException(String.format("File[%s] not exit in hdfs", filePath));
    }
    return fs.open(hdfsFilePath);
}
Also used : Path(org.apache.hadoop.fs.Path) PluginDefineException(com.dtstack.taier.pluginapi.exception.PluginDefineException) FileSystem(org.apache.hadoop.fs.FileSystem) URI(java.net.URI)

Aggregations

PluginDefineException (com.dtstack.taier.pluginapi.exception.PluginDefineException)58 IOException (java.io.IOException)30 File (java.io.File)13 MalformedURLException (java.net.MalformedURLException)13 YarnClient (org.apache.hadoop.yarn.client.api.YarnClient)11 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)10 JarFileInfo (com.dtstack.taier.pluginapi.JarFileInfo)8 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)8 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)8 ApplicationReport (org.apache.hadoop.yarn.api.records.ApplicationReport)7 YarnApplicationState (org.apache.hadoop.yarn.api.records.YarnApplicationState)7 ClusterClient (org.apache.flink.client.program.ClusterClient)6 JSONObject (com.alibaba.fastjson.JSONObject)5 Configuration (org.apache.flink.configuration.Configuration)5 Path (org.apache.hadoop.fs.Path)5 KerberosUtils (com.dtstack.taier.base.util.KerberosUtils)4 FlinkConfig (com.dtstack.taier.flink.FlinkConfig)4 ConfigConstant (com.dtstack.taier.pluginapi.constrant.ConfigConstant)4 URL (java.net.URL)4 Matcher (java.util.regex.Matcher)4