本文整理汇总了Java中azkaban.project.ProjectManagerException类的典型用法代码示例。如果您正苦于以下问题:Java ProjectManagerException类的具体用法?Java ProjectManagerException怎么用?Java ProjectManagerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProjectManagerException类属于azkaban.project包,在下文中一共展示了ProjectManagerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareProject
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
private void prepareProject(Project project, File directory)
throws ProjectManagerException, IOException {
DirectoryFlowLoader loader = new DirectoryFlowLoader(new Props(), logger);
loader.loadProjectFlow(project, directory);
if (!loader.getErrors().isEmpty()) {
for (String error: loader.getErrors()) {
System.out.println(error);
}
throw new RuntimeException("Errors found in setup");
}
flowMap = loader.getFlowMap();
project.setFlows(flowMap);
FileUtils.copyDirectory(directory, workingDir);
}
示例2: prepareProject
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
private void prepareProject(Project project, File directory) throws ProjectManagerException,
IOException {
DirectoryFlowLoader loader = new DirectoryFlowLoader(new Props(), logger);
loader.loadProjectFlow(project, directory);
if (!loader.getErrors().isEmpty()) {
for (String error : loader.getErrors()) {
System.out.println(error);
}
throw new RuntimeException("Errors found in setup");
}
flowMap = loader.getFlowMap();
project.setFlows(flowMap);
FileUtils.copyDirectory(directory, workingDir);
}
示例3: testCreateProject
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
@Test
public void testCreateProject() throws ProjectManagerException {
if (!isTestSetup()) {
return;
}
ProjectLoader loader = createLoader();
String projectName = "mytestProject";
String projectDescription = "This is my new project";
User user = new User("testUser");
Project project = loader.createNewProject(projectName, projectDescription, user);
Assert.assertTrue("Project Id set", project.getId() > -1);
Assert.assertEquals("Project name", projectName, project.getName());
Assert.assertEquals("Project description", projectDescription, project.getDescription());
System.out.println("Test true");
Project project2 = loader.fetchProjectById(project.getId());
assertProjectMemberEquals(project, project2);
}
示例4: testProjectEventLogs
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
@Test
public void testProjectEventLogs() throws ProjectManagerException {
if (!isTestSetup()) {
return;
}
ProjectLoader loader = createLoader();
String projectName = "testProjectEventLogs";
String projectDescription = "This is my new project";
User user = new User("testUser");
String message = "My message";
EventType type = EventType.USER_PERMISSION;
Project project = loader.createNewProject(projectName, projectDescription, user);
loader.postEvent(project, type, user.getUserId(), message);
List<ProjectLogEvent> events = loader.getProjectEvents(project, 10, 0);
Assert.assertTrue(events.size() == 1);
ProjectLogEvent event = events.get(0);
Assert.assertEquals(event.getProjectId(), project.getId());
Assert.assertEquals(event.getUser(), user.getUserId());
Assert.assertEquals(event.getMessage(), message);
Assert.assertEquals(event.getType(), type);
}
示例5: testProjectProperties
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
@Test
public void testProjectProperties() throws ProjectManagerException {
ProjectLoader loader = createLoader();
((JdbcProjectLoader)loader).setDefaultEncodingType(JdbcProjectLoader.EncodingType.PLAIN);
String projectName = "testProjectProperties";
String projectDescription = "This is my new project";
User user = new User("testUser");
Project project = loader.createNewProject(projectName, projectDescription, user);
project.setVersion(5);
Props props = new Props();
props.put("a", "abc");
props.put("b", "bcd");
props.put("c", "cde");
props.setSource("mysource");
loader.uploadProjectProperty(project, props);
Props retProps = loader.fetchProjectProperty(project, "mysource");
Assert.assertEquals(retProps.getSource(), props.getSource());
Assert.assertEquals(retProps.getKeySet(), props.getKeySet());
Assert.assertEquals(PropsUtils.toStringMap(retProps, true), PropsUtils.toStringMap(props, true));
}
示例6: fetchProjectProperties
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
@Override
public Map<String, Props> fetchProjectProperties(int projectId, int version)
throws ProjectManagerException {
Map<String, Props> propertyMap = new HashMap<String, Props>();
for (File file: dir.listFiles()) {
String name = file.getName();
if (name.endsWith(".job") || name.endsWith(".properties")) {
try {
Props props = new Props(null, file);
propertyMap.put(name, props);
} catch (IOException e) {
throw new ProjectManagerException(e.getMessage());
}
}
}
return propertyMap;
}
示例7: ajaxSetJobOverrideProperty
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
private void ajaxSetJobOverrideProperty(Project project, HashMap<String, Object> ret, HttpServletRequest req) throws ServletException {
String flowName = getParam(req, "flowName");
String jobName = getParam(req, "jobName");
Flow flow = project.getFlow(flowName);
if(flow == null) {
ret.put("error", "Flow " + flowName + " not found in project " + project.getName());
return;
}
Node node = flow.getNode(jobName);
if(node == null) {
ret.put("error", "Job " + jobName + " not found in flow " + flowName);
return;
}
Map<String, String> jobParamGroup = this.getParamGroup(req, "jobOverride");
@SuppressWarnings("unchecked")
Props overrideParams = new Props(null, jobParamGroup);
try {
projectManager.setJobOverrideProperty(project, overrideParams, jobName);
} catch (ProjectManagerException e) {
ret.put("error", "Failed to upload job override property");
}
}
示例8: ajaxAddProxyUser
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
private void ajaxAddProxyUser(Project project, HashMap<String, Object> ret, HttpServletRequest req, User user) throws ServletException {
String name = getParam(req, "name");
logger.info("Adding proxy user " + name + " by " + user.getUserId());
if(userManager.validateProxyUser(name, user)) {
try {
projectManager.addProjectProxyUser(project, name, user);
} catch (ProjectManagerException e) {
ret.put("error", e.getMessage());
}
}
else {
ret.put("error", "User " + user.getUserId() + " has no permission to add " + name + " as proxy user.");
return;
}
}
示例9: subscribeProject
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
public static void subscribeProject(AzkabanWebServer server, Project project,
User user, String email) throws ProjectManagerException {
@SuppressWarnings("unchecked")
Map<String, String> subscription =
(Map<String, String>) project.getMetadata().get("subscription");
if (subscription == null) {
subscription = new HashMap<String, String>();
}
if (email != null && !email.isEmpty()) {
subscription.put(user.getUserId(), email);
}
project.getMetadata().put("subscription", subscription);
updateProjectNotifications(project, server.getProjectManager());
server.getProjectManager().updateProjectSetting(project);
}
示例10: setupProjectFiles
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
public synchronized void setupProjectFiles(ProjectLoader projectLoader, File projectDir, Logger logger) throws ProjectManagerException,
IOException {
String projectVersion = String.valueOf(projectId) + "." + String.valueOf(version);
if (installedDir == null) {
installedDir = new File(projectDir, projectVersion);
}
if (!installedDir.exists()) {
logger.info("First time executing new project. Setting up in directory " + installedDir.getPath());
File tempDir = new File(projectDir, "_temp." + projectVersion + "." + System.currentTimeMillis());
tempDir.mkdirs();
ProjectFileHandler projectFileHandler = null;
try {
//修改从mysql获取文件的逻辑
projectFileHandler = projectLoader.getUploadedFilePath(projectId, version);
if (projectFileHandler == null ) {
projectFileHandler = projectLoader.getUploadedFile(projectId, version);
}
if ("zip".equals(projectFileHandler.getFileType())) {
logger.info("Downloading zip file.");
ZipFile zip = new ZipFile(projectFileHandler.getLocalFile());
Utils.unzip(zip, tempDir);
tempDir.renameTo(installedDir);
processInitParameter();
} else {
throw new IOException("The file type hasn't been decided yet.");
}
} finally {
if (projectFileHandler != null) {
projectFileHandler.deleteLocalFile();
}
}
} else {
processInitParameter();
}
}
示例11: testRemoveProject
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
@Test
public void testRemoveProject() throws ProjectManagerException {
if (!isTestSetup()) {
return;
}
ProjectLoader loader = createLoader();
String projectName = "testRemoveProject";
String projectDescription = "This is my new project";
User user = new User("testUser");
Project project = loader.createNewProject(projectName, projectDescription, user);
Assert.assertTrue("Project Id set", project.getId() > -1);
Assert.assertEquals("Project name", projectName, project.getName());
Assert.assertEquals("Project description", projectDescription, project.getDescription());
Project project2 = loader.fetchProjectById(project.getId());
assertProjectMemberEquals(project, project2);
loader.removeProject(project, user.getUserId());
Project project3 = loader.fetchProjectById(project.getId());
Assert.assertFalse(project3.isActive());
List<Project> projList = loader.fetchAllActiveProjects();
for (Project proj: projList) {
Assert.assertTrue(proj.getId() != project.getId());
}
}
示例12: testAddRemovePermissions
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
@Test
public void testAddRemovePermissions() throws ProjectManagerException {
if (!isTestSetup()) {
return;
}
ProjectLoader loader = createLoader();
String projectName = "mytestProject1";
String projectDescription = "This is my new project";
User user = new User("testUser");
Project project = loader.createNewProject(projectName, projectDescription, user);
Assert.assertTrue("Project Id set", project.getId() > -1);
Assert.assertEquals("Project name", projectName, project.getName());
Assert.assertEquals("Project description", projectDescription, project.getDescription());
Permission perm = new Permission(0x2);
loader.updatePermission(project, user.getUserId(), new Permission(0x2), false);
loader.updatePermission(project, "group1", new Permission(0x2), true);
Assert.assertEquals(perm, project.getUserPermission(user.getUserId()));
Permission permOverride = new Permission(0x6);
loader.updatePermission(project, user.getUserId(), permOverride, false);
Assert.assertEquals(permOverride, project.getUserPermission(user.getUserId()));
Project project2 = loader.fetchProjectById(project.getId());
assertProjectMemberEquals(project, project2);
Assert.assertEquals(permOverride, project2.getUserPermission(user.getUserId()));
}
示例13: testFlowUpload
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
@Test
public void testFlowUpload() throws ProjectManagerException {
ProjectLoader loader = createLoader();
((JdbcProjectLoader)loader).setDefaultEncodingType(JdbcProjectLoader.EncodingType.GZIP);
String projectName = "mytestFlowUpload1";
String projectDescription = "This is my new project";
User user = new User("testUser");
Project project = loader.createNewProject(projectName, projectDescription, user);
Flow flow = new Flow("MyNewFlow");
flow.addNode(new Node("A"));
flow.addNode(new Node("B"));
flow.addNode(new Node("C"));
flow.addNode(new Node("D"));
flow.addEdge(new Edge("A", "B"));
flow.addEdge(new Edge("A", "C"));
flow.addEdge(new Edge("B", "D"));
flow.addEdge(new Edge("C", "D"));
flow.initialize();
loader.uploadFlow(project, 4, flow);
project.setVersion(4);
Flow newFlow = loader.fetchFlow(project, flow.getId());
Assert.assertTrue(newFlow != null);
Assert.assertEquals(flow.getId(), newFlow.getId());
Assert.assertEquals(flow.getEdges().size(), newFlow.getEdges().size());
Assert.assertEquals(flow.getNodes().size(), newFlow.getNodes().size());
}
示例14: testFlowUploadPlain
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
@Test
public void testFlowUploadPlain() throws ProjectManagerException {
ProjectLoader loader = createLoader();
((JdbcProjectLoader)loader).setDefaultEncodingType(JdbcProjectLoader.EncodingType.PLAIN);
String projectName = "mytestFlowUpload2";
String projectDescription = "This is my new project";
User user = new User("testUser");
Project project = loader.createNewProject(projectName, projectDescription, user);
Flow flow = new Flow("MyNewFlow2");
flow.addNode(new Node("A1"));
flow.addNode(new Node("B1"));
flow.addNode(new Node("C1"));
flow.addNode(new Node("D1"));
flow.addEdge(new Edge("A1", "B1"));
flow.addEdge(new Edge("A1", "C1"));
flow.addEdge(new Edge("B1", "D1"));
flow.addEdge(new Edge("C1", "D1"));
flow.initialize();
loader.uploadFlow(project, 4, flow);
project.setVersion(4);
Flow newFlow = loader.fetchFlow(project, flow.getId());
Assert.assertTrue(newFlow != null);
Assert.assertEquals(flow.getId(), newFlow.getId());
Assert.assertEquals(flow.getEdges().size(), newFlow.getEdges().size());
Assert.assertEquals(flow.getNodes().size(), newFlow.getNodes().size());
List<Flow> flows = loader.fetchAllProjectFlows(project);
Assert.assertTrue(flows.size() == 1);
}
示例15: testProjectFilesUpload
import azkaban.project.ProjectManagerException; //导入依赖的package包/类
@Test
public void testProjectFilesUpload() throws ProjectManagerException {
if (!isTestSetup()) {
return;
}
ProjectLoader loader = createLoader();
String projectName = "testProjectFilesUpload1";
String projectDescription = "This is my new project";
User user = new User("testUser");
Project project = loader.createNewProject(projectName, projectDescription, user);
Assert.assertTrue("Project Id set", project.getId() > -1);
Assert.assertEquals("Project name", projectName, project.getName());
Assert.assertEquals("Project description", projectDescription, project.getDescription());
File testDir = new File("unit/project/testjob/testjob.zip");
loader.uploadProjectFile(project, 1, "zip", "testjob.zip", testDir, user.getUserId());
ProjectFileHandler handler = loader.getUploadedFile(project, 1);
Assert.assertEquals(handler.getProjectId(), project.getId());
Assert.assertEquals(handler.getFileName(), "testjob.zip");
Assert.assertEquals(handler.getVersion(), 1);
Assert.assertEquals(handler.getFileType(), "zip");
File file = handler.getLocalFile();
Assert.assertTrue(handler.getLocalFile().exists());
Assert.assertEquals(handler.getFileName(), "testjob.zip");
Assert.assertEquals(handler.getUploader(), user.getUserId());
handler.deleteLocalFile();
Assert.assertTrue(handler.getLocalFile() == null);
Assert.assertFalse(file.exists());
}