Browse Source
* init full_name in dml of version 1.2.2 * redefine request parameter resourceIds * redefine request parameter resourceIds * Actually grant resource file if choose the directory * To cancel authorized resource need check whether it is used by the process definition which is online * If release the process definition online,It is necessary to check whether resource is valid * update ResourceServiceTest and ResourceMapperTest * add batchUpdateResourceTest * add getHdfsFileNameTest and getHdfsResourceFileNameTest * update ResourceServiceTest and ResourceMapperTest * extract getResourceProcessMap to ResourceProcessDefinitonUtils Co-authored-by: dailidong <dailidong66@gmail.com>pull/2/head
lgcareer
5 years ago
committed by
GitHub
18 changed files with 386 additions and 81 deletions
@ -0,0 +1,61 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.dao.utils; |
||||
|
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils; |
||||
|
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* resource process definition utils |
||||
*/ |
||||
public class ResourceProcessDefinitionUtils { |
||||
/** |
||||
* get resource process map key is resource id,value is the set of process definition |
||||
* @param list the map key is process definition id and value is resource_ids |
||||
* @return resource process definition map |
||||
*/ |
||||
public static Map<Integer, Set<Integer>> getResourceProcessDefinitionMap(List<Map<String, Object>> list) { |
||||
Map<Integer, String> map = new HashMap<>(); |
||||
Map<Integer, Set<Integer>> result = new HashMap<>(); |
||||
if (CollectionUtils.isNotEmpty(list)) { |
||||
for (Map<String, Object> tempMap : list) { |
||||
|
||||
map.put((Integer) tempMap.get("id"), (String)tempMap.get("resource_ids")); |
||||
} |
||||
} |
||||
|
||||
for (Map.Entry<Integer, String> entry : map.entrySet()) { |
||||
Integer mapKey = entry.getKey(); |
||||
String[] arr = entry.getValue().split(","); |
||||
Set<Integer> mapValues = Arrays.stream(arr).map(Integer::parseInt).collect(Collectors.toSet()); |
||||
for (Integer value : mapValues) { |
||||
if (result.containsKey(value)) { |
||||
Set<Integer> set = result.get(value); |
||||
set.add(mapKey); |
||||
result.put(value, set); |
||||
} else { |
||||
Set<Integer> set = new HashSet<>(); |
||||
set.add(mapKey); |
||||
result.put(value, set); |
||||
} |
||||
} |
||||
} |
||||
return result; |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.dao.utils; |
||||
|
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* resource process definition utils test |
||||
*/ |
||||
public class ResourceProcessDefinitionUtilsTest { |
||||
@Test |
||||
public void getResourceProcessDefinitionMapTest(){ |
||||
List<Map<String,Object>> mapList = new ArrayList<>(); |
||||
Map<String,Object> map = new HashMap(); |
||||
map.put("id",1); |
||||
map.put("resource_ids","1,2,3"); |
||||
mapList.add(map); |
||||
Assert.assertNotNull(ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(mapList)); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue