Search in sources :

Example 61 with XmlPullParserException

use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project zeppelin by apache.

the class SparkIntegrationTest method testYarnClusterMode.

@Test
public void testYarnClusterMode() throws IOException, YarnException, InterruptedException, InterpreterException, XmlPullParserException {
    assumeTrue("Hadoop version mismatch, skip test", isHadoopVersionMatch());
    InterpreterSetting sparkInterpreterSetting = interpreterSettingManager.getInterpreterSettingByName("spark");
    sparkInterpreterSetting.setProperty("spark.master", "yarn-cluster");
    sparkInterpreterSetting.setProperty("HADOOP_CONF_DIR", hadoopCluster.getConfigPath());
    sparkInterpreterSetting.setProperty("SPARK_HOME", sparkHome);
    sparkInterpreterSetting.setProperty("ZEPPELIN_CONF_DIR", zeppelin.getZeppelinConfDir().getAbsolutePath());
    sparkInterpreterSetting.setProperty("zeppelin.spark.useHiveContext", "false");
    sparkInterpreterSetting.setProperty("zeppelin.pyspark.useIPython", "false");
    sparkInterpreterSetting.setProperty("PYSPARK_PYTHON", getPythonExec());
    sparkInterpreterSetting.setProperty("spark.driver.memory", "512m");
    sparkInterpreterSetting.setProperty("zeppelin.spark.scala.color", "false");
    sparkInterpreterSetting.setProperty("zeppelin.spark.deprecatedMsg.show", "false");
    sparkInterpreterSetting.setProperty("spark.user.name", "#{user}");
    sparkInterpreterSetting.setProperty("zeppelin.spark.run.asLoginUser", "false");
    // parameters with whitespace
    sparkInterpreterSetting.setProperty("spark.app.name", "hello spark");
    String yarnAppId = null;
    try {
        setUpSparkInterpreterSetting(sparkInterpreterSetting);
        testInterpreterBasics();
        // 1 yarn application launched
        GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.RUNNING));
        GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
        assertEquals(1, response.getApplicationList().size());
        assertEquals("hello spark", response.getApplicationList().get(0).getName());
        yarnAppId = response.getApplicationList().get(0).getApplicationId().toString();
    } finally {
        interpreterSettingManager.close();
        waitForYarnAppCompleted(30 * 1000);
        if (yarnAppId != null) {
            // ensure yarn app is finished with SUCCEEDED status.
            final String finalYarnAppId = yarnAppId;
            GetApplicationsRequest request = GetApplicationsRequest.newInstance(EnumSet.of(YarnApplicationState.FINISHED));
            GetApplicationsResponse response = hadoopCluster.getYarnCluster().getResourceManager().getClientRMService().getApplications(request);
            List<ApplicationReport> apps = response.getApplicationList().stream().filter(app -> app.getApplicationId().toString().equals(finalYarnAppId)).collect(Collectors.toList());
            assertEquals(1, apps.size());
            assertEquals(FinalApplicationStatus.SUCCEEDED, apps.get(0).getFinalApplicationStatus());
        }
    }
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) GetApplicationsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) BeforeClass(org.junit.BeforeClass) LoggerFactory(org.slf4j.LoggerFactory) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) InterpreterFactory(org.apache.zeppelin.interpreter.InterpreterFactory) ExecutionContext(org.apache.zeppelin.interpreter.ExecutionContext) DownloadUtils(org.apache.zeppelin.interpreter.integration.DownloadUtils) EnumSet(java.util.EnumSet) Interpreter(org.apache.zeppelin.interpreter.Interpreter) InterpreterException(org.apache.zeppelin.interpreter.InterpreterException) InterpreterSettingManager(org.apache.zeppelin.interpreter.InterpreterSettingManager) AfterClass(org.junit.AfterClass) Logger(org.slf4j.Logger) InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) File(java.io.File) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) GetApplicationsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse) FinalApplicationStatus(org.apache.hadoop.yarn.api.records.FinalApplicationStatus) InterpreterOption(org.apache.zeppelin.interpreter.InterpreterOption) YarnApplicationState(org.apache.hadoop.yarn.api.records.YarnApplicationState) Assume.assumeTrue(org.junit.Assume.assumeTrue) FileReader(java.io.FileReader) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) Assert.assertEquals(org.junit.Assert.assertEquals) Model(org.apache.maven.model.Model) GetApplicationsResponse(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse) InterpreterSetting(org.apache.zeppelin.interpreter.InterpreterSetting) GetApplicationsRequest(org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest) Test(org.junit.Test)

Example 62 with XmlPullParserException

use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-plugins by apache.

the class DefaultAssemblyArchiver method configureArchiver.

private void configureArchiver(final Archiver archiver, final AssemblerConfigurationSource configSource) {
    Xpp3Dom config;
    try {
        config = Xpp3DomBuilder.build(new StringReader(configSource.getArchiverConfig()));
    } catch (final XmlPullParserException e) {
        throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
    } catch (final IOException e) {
        throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
    }
    getLogger().debug("Configuring archiver: '" + archiver.getClass().getName() + "' -->");
    try {
        configureComponent(archiver, config, configSource);
    } catch (final ComponentConfigurationException e) {
        throw new ArchiverException("Failed to configure archiver: " + archiver.getClass().getName(), e);
    } catch (final ComponentLookupException e) {
        throw new ArchiverException("Failed to lookup configurator for setup of archiver: " + archiver.getClass().getName(), e);
    }
    getLogger().debug("-- end configuration --");
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) NoSuchArchiverException(org.codehaus.plexus.archiver.manager.NoSuchArchiverException) StringReader(java.io.StringReader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) ComponentConfigurationException(org.codehaus.plexus.component.configurator.ComponentConfigurationException)

Example 63 with XmlPullParserException

use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-plugins by apache.

the class PomUtils method loadPom.

/**
 * Loads the (raw) model from the specified POM file.
 *
 * @param pomFile The path to the POM file to load, must not be <code>null</code>.
 * @return The raw model, never <code>null</code>.
 * @throws MojoExecutionException If the POM file could not be loaded.
 */
public static Model loadPom(File pomFile) throws MojoExecutionException {
    Reader reader = null;
    try {
        reader = ReaderFactory.newXmlReader(pomFile);
        final Model model = new MavenXpp3Reader().read(reader, false);
        reader.close();
        reader = null;
        return model;
    } catch (XmlPullParserException e) {
        throw new MojoExecutionException("Failed to parse POM: " + pomFile, e);
    } catch (IOException e) {
        throw new MojoExecutionException("Failed to read POM: " + pomFile, e);
    } finally {
        IOUtil.close(reader);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Model(org.apache.maven.model.Model) Reader(java.io.Reader) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException)

Example 64 with XmlPullParserException

use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-plugins by apache.

the class PdfMojo method getDefaultDecorationModel.

/**
 * @return the DecorationModel instance from <code>site.xml</code>
 * @throws MojoExecutionException if any
 */
private DecorationModel getDefaultDecorationModel() throws MojoExecutionException {
    if (this.defaultDecorationModel == null) {
        final Locale locale = getDefaultLocale();
        final File descriptorFile = siteTool.getSiteDescriptor(siteDirectory, locale);
        DecorationModel decoration = null;
        if (descriptorFile.exists()) {
            XmlStreamReader reader = null;
            try {
                reader = new XmlStreamReader(descriptorFile);
                String siteDescriptorContent = IOUtil.toString(reader);
                reader.close();
                reader = null;
                siteDescriptorContent = siteTool.getInterpolatedSiteDescriptorContent(new HashMap<String, String>(2), project, siteDescriptorContent);
                decoration = new DecorationXpp3Reader().read(new StringReader(siteDescriptorContent));
            } catch (XmlPullParserException e) {
                throw new MojoExecutionException("Error parsing site descriptor", e);
            } catch (IOException e) {
                throw new MojoExecutionException("Error reading site descriptor", e);
            } catch (SiteToolException e) {
                throw new MojoExecutionException("Error when interpoling site descriptor", e);
            } finally {
                IOUtil.close(reader);
            }
        }
        this.defaultDecorationModel = decoration;
    }
    return this.defaultDecorationModel;
}
Also used : Locale(java.util.Locale) DecorationModel(org.apache.maven.doxia.site.decoration.DecorationModel) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) HashMap(java.util.HashMap) StringReader(java.io.StringReader) XmlStreamReader(org.apache.commons.io.input.XmlStreamReader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException) DecorationXpp3Reader(org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader) File(java.io.File) SiteToolException(org.apache.maven.doxia.tools.SiteToolException)

Example 65 with XmlPullParserException

use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-plugins by apache.

the class DefaultAssemblyReader method mergeComponentsWithMainAssembly.

/**
 * Add the contents of all included components to main assembly
 *
 * @param assembly The assembly
 * @param assemblyDir The assembly directory
 * @param transformer The component interpolator
 * @throws AssemblyReadException .
 */
protected void mergeComponentsWithMainAssembly(final Assembly assembly, final File assemblyDir, final AssemblerConfigurationSource configSource, ComponentXpp3Reader.ContentTransformer transformer) throws AssemblyReadException {
    final Locator locator = new Locator();
    if (assemblyDir != null && assemblyDir.exists() && assemblyDir.isDirectory()) {
        locator.addStrategy(new RelativeFileLocatorStrategy(assemblyDir));
    }
    // allow absolute paths in componentDescriptor... MASSEMBLY-486
    locator.addStrategy(new RelativeFileLocatorStrategy(configSource.getBasedir()));
    locator.addStrategy(new FileLocatorStrategy());
    locator.addStrategy(new ClasspathResourceLocatorStrategy());
    final AssemblyExpressionEvaluator aee = new AssemblyExpressionEvaluator(configSource);
    final List<String> componentLocations = assembly.getComponentDescriptors();
    for (String location : componentLocations) {
        // allow expressions in path to component descriptor... MASSEMBLY-486
        try {
            location = aee.evaluate(location).toString();
        } catch (final Exception eee) {
            getLogger().error("Error interpolating componentDescriptor: " + location, eee);
        }
        final Location resolvedLocation = locator.resolve(location);
        if (resolvedLocation == null) {
            throw new AssemblyReadException("Failed to locate component descriptor: " + location);
        }
        Component component = null;
        Reader reader = null;
        try {
            reader = new InputStreamReader(resolvedLocation.getInputStream());
            component = new ComponentXpp3Reader(transformer).read(reader);
        } catch (final IOException e) {
            throw new AssemblyReadException("Error reading component descriptor: " + location + " (resolved to: " + resolvedLocation.getSpecification() + ")", e);
        } catch (final XmlPullParserException e) {
            throw new AssemblyReadException("Error reading component descriptor: " + location + " (resolved to: " + resolvedLocation.getSpecification() + ")", e);
        } finally {
            IOUtil.close(reader);
        }
        mergeComponentWithAssembly(component, assembly);
    }
}
Also used : AssemblyExpressionEvaluator(org.apache.maven.plugins.assembly.interpolation.AssemblyExpressionEvaluator) InputStreamReader(java.io.InputStreamReader) FileLocatorStrategy(org.apache.maven.shared.io.location.FileLocatorStrategy) ComponentXpp3Reader(org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Reader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) AssemblyXpp3Reader(org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Reader) IOException(java.io.IOException) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) IOException(java.io.IOException) InvalidAssemblerConfigurationException(org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException) Locator(org.apache.maven.shared.io.location.Locator) ComponentXpp3Reader(org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Reader) XmlPullParserException(org.codehaus.plexus.util.xml.pull.XmlPullParserException) Component(org.apache.maven.plugins.assembly.model.Component) ClasspathResourceLocatorStrategy(org.apache.maven.shared.io.location.ClasspathResourceLocatorStrategy) Location(org.apache.maven.shared.io.location.Location)

Aggregations

XmlPullParserException (org.codehaus.plexus.util.xml.pull.XmlPullParserException)79 IOException (java.io.IOException)73 File (java.io.File)37 Model (org.apache.maven.model.Model)32 MavenXpp3Reader (org.apache.maven.model.io.xpp3.MavenXpp3Reader)30 FileNotFoundException (java.io.FileNotFoundException)20 Reader (java.io.Reader)20 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)19 FileReader (java.io.FileReader)15 FileInputStream (java.io.FileInputStream)12 ArrayList (java.util.ArrayList)12 InputStream (java.io.InputStream)11 StringReader (java.io.StringReader)10 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)10 Path (java.nio.file.Path)7 Artifact (org.eclipse.aether.artifact.Artifact)7 DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)7 PluginException (org.bimserver.shared.exceptions.PluginException)6 ArtifactDescriptorException (org.eclipse.aether.resolution.ArtifactDescriptorException)6 HashMap (java.util.HashMap)5