clazz, int code){
29 | for(T enu:clazz.getEnumConstants()){
30 | if(code==enu.getCode()){
31 | return enu;
32 | }
33 | }
34 | return null;
35 | }
36 |
37 |
38 | public static void main(String[] args) {
39 | Alarm.AlarmType enumBycode = EnumUtil.getEnumBycode(Alarm.AlarmType.class, 8);
40 | System.out.println(enumBycode);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/domain/JobAgent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.domain;
22 |
23 | /**
24 | * job分布在哪些agent上
25 | */
26 | public class JobAgent {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/Cleanable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 |
23 | package com.jobxhub.common.serialize;
24 |
25 | public interface Cleanable {
26 |
27 | void cleanup();
28 | }
29 |
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/support/ChannelWrapper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.rpc.support;
23 |
24 | public interface ChannelWrapper {
25 | boolean isActive();
26 | void close();
27 | }
28 |
--------------------------------------------------------------------------------
/jobx-server/src/main/webapp/static/js/My97DatePicker/lang/zh-cn.js:
--------------------------------------------------------------------------------
1 | var $lang={
2 | errAlertMsg: "\u4E0D\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F\u6216\u8005\u65E5\u671F\u8D85\u51FA\u9650\u5B9A\u8303\u56F4,\u9700\u8981\u64A4\u9500\u5417?",
3 | aWeekStr: ["\u5468","\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],
4 | aLongWeekStr:["\u5468","\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"],
5 | aMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00","\u5341\u4E8C"],
6 | aLongMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"],
7 | clearStr: "\u6E05\u7A7A",
8 | todayStr: "\u4ECA\u5929",
9 | okStr: "\u786E\u5B9A",
10 | updateStr: "\u786E\u5B9A",
11 | timeStr: "\u65F6\u95F4",
12 | quickStr: "\u5FEB\u901F\u9009\u62E9",
13 | err_1: '\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u6700\u5927\u65E5\u671F!'
14 | }
--------------------------------------------------------------------------------
/jobx-server/src/main/webapp/static/js/My97DatePicker/lang/zh-tw.js:
--------------------------------------------------------------------------------
1 | var $lang={
2 | errAlertMsg: "\u4E0D\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F\u6216\u8005\u65E5\u671F\u8D85\u51FA\u9650\u5B9A\u7BC4\u570D,\u9700\u8981\u64A4\u92B7\u55CE?",
3 | aWeekStr: ["\u5468","\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"],
4 | aLongWeekStr:["\u5468","\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"],
5 | aMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00","\u5341\u4E8C"],
6 | aLongMonStr: ["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"],
7 | clearStr: "\u6E05\u7A7A",
8 | todayStr: "\u4ECA\u5929",
9 | okStr: "\u78BA\u5B9A",
10 | updateStr: "\u78BA\u5B9A",
11 | timeStr: "\u6642\u9593",
12 | quickStr: "\u5FEB\u901F\u9078\u64C7",
13 | err_1: '\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u65BC\u6700\u5927\u65E5\u671F!'
14 | }
--------------------------------------------------------------------------------
/jobx-registry/src/main/java/com/jobxhub/registry/zookeeper/ChildListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.registry.zookeeper;
23 |
24 | import java.util.List;
25 |
26 | public interface ChildListener {
27 |
28 | void childChanged(String path, List children);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/Server.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.rpc;
22 |
23 |
24 | import com.jobxhub.common.ext.SPI;
25 |
26 | @SPI
27 | public interface Server {
28 |
29 | void start(int port, ServerHandler handler);
30 |
31 | void destroy() throws Throwable;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/ext/ClassMark.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.ext;
23 |
24 | import java.lang.annotation.*;
25 |
26 | @Documented
27 | @Retention(RetentionPolicy.RUNTIME)
28 | @Target({ElementType.TYPE})
29 | public @interface ClassMark {
30 | String value() default "";
31 | }
32 |
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/InvokeCallback.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.rpc;
22 |
23 | import com.jobxhub.common.job.Response;
24 |
25 | /**
26 | * @author benjobs
27 | */
28 | public interface InvokeCallback {
29 |
30 | void done(Response response);
31 |
32 | void caught(Throwable err);
33 |
34 | }
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/ext/MethodMark.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.ext;
23 |
24 | import java.lang.annotation.*;
25 |
26 | @Documented
27 | @Retention(RetentionPolicy.RUNTIME)
28 | @Target({ElementType.METHOD})
29 | public @interface MethodMark {
30 | String value() default "";
31 | }
32 |
--------------------------------------------------------------------------------
/jobx-server/src/main/webapp/static/js/bootstrap-select/bootstrap-select-lang.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap-select v1.12.2 (http://silviomoreto.github.io/bootstrap-select)
3 | *
4 | * Copyright 2013-2017 bootstrap-select
5 | * Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
6 | */
7 |
8 | (function (root, factory) {
9 | if (typeof define === 'function' && define.amd) {
10 | // AMD. Register as an anonymous module unless amdModuleId is set
11 | define(["jquery"], function (a0) {
12 | return (factory(a0));
13 | });
14 | } else if (typeof module === 'object' && module.exports) {
15 | // Node. Does not work with strict CommonJS, but
16 | // only CommonJS-like environments that support module.exports,
17 | // like Node.
18 | module.exports = factory(require("jquery"));
19 | } else {
20 | factory(root["jQuery"]);
21 | }
22 | }(this, function (jQuery) {
23 |
24 | (function ($) {
25 | $.fn.selectpicker.defaults = {
26 | noneSelectedText: '请选择执行器',
27 | noneResultsText: '没有找到匹配的执行器',
28 | countSelectedText: '选中{1}中的{0}项',
29 | maxOptionsText: ['超出限制 (最多选择{n}项)', '组选择超出限制(最多选择{n}组)'],
30 | multipleSeparator: ', '
31 | };
32 | })(jQuery);
33 |
34 |
35 | }));
36 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/util/Holder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.util;
23 |
24 | public class Holder {
25 |
26 | private volatile T value;
27 |
28 | public void set(T value) {
29 | this.value = value;
30 | }
31 |
32 | public T get() {
33 | return value;
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/jobx-registry/src/main/java/com/jobxhub/registry/zookeeper/StateListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.registry.zookeeper;
23 |
24 | public interface StateListener {
25 |
26 | int DISCONNECTED = 0;
27 |
28 | int CONNECTED = 1;
29 |
30 | int RECONNECTED = 2;
31 |
32 | void stateChanged(int connected);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/Client.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.rpc;
22 |
23 | import com.jobxhub.common.ext.SPI;
24 | import com.jobxhub.common.job.Request;
25 |
26 | @SPI
27 | public interface Client extends Invoker {
28 |
29 | void connect(Request request);
30 |
31 | void disconnect() throws Throwable;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/ServerHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.rpc;
23 |
24 | import com.jobxhub.common.ext.SPI;
25 | import com.jobxhub.common.job.Request;
26 | import com.jobxhub.common.job.Response;
27 |
28 | @SPI
29 | public interface ServerHandler {
30 |
31 | Response handle(Request request);
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/service/QuartzExecutor.java:
--------------------------------------------------------------------------------
1 | package com.jobxhub.server.service;
2 |
3 | import com.jobxhub.common.Constants;
4 | import com.jobxhub.server.dto.Job;
5 | import org.quartz.JobExecutionContext;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 | import org.springframework.stereotype.Component;
9 |
10 |
11 | @Component
12 | public class QuartzExecutor implements org.quartz.Job {
13 |
14 | private Logger logger = LoggerFactory.getLogger(getClass());
15 |
16 | @Override
17 | public void execute(JobExecutionContext jobExecutionContext) {
18 | String key = jobExecutionContext.getJobDetail().getKey().getName();
19 | Job job = (Job) jobExecutionContext.getJobDetail().getJobDataMap().get(key);
20 | try {
21 | ExecuteService executeService = (ExecuteService) jobExecutionContext.getJobDetail().getJobDataMap().get("executor");
22 | executeService.executeJob(job, Constants.ExecType.AUTO);
23 | logger.info("[JobX] job:{} at {}:{}", job, null);
24 | } catch (Exception e) {
25 | if (logger.isErrorEnabled()) {
26 | logger.error(e.getLocalizedMessage(), e);
27 | }
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/jobx-registry/src/main/java/com/jobxhub/registry/zookeeper/ZookeeperTransporter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.registry.zookeeper;
23 |
24 |
25 | import com.jobxhub.common.ext.SPI;
26 | import com.jobxhub.registry.URL;
27 |
28 | @SPI
29 | public interface ZookeeperTransporter {
30 |
31 | ZookeeperClient connect(URL url);
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/dao/RoleDao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.dao;
22 |
23 | import com.jobxhub.server.domain.RoleBean;
24 |
25 | import java.util.List;
26 |
27 | public interface RoleDao {
28 | List getAll();
29 |
30 | RoleBean getById(Long roleId);
31 |
32 | void save(RoleBean role);
33 | }
34 |
--------------------------------------------------------------------------------
/jobx-server/src/main/resources/mapper/UserAgentDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | delete from t_user_agent where user_id=#{userId}
8 |
9 |
10 |
11 | insert into t_user_agent (
12 | user_id,
13 | agent_id
14 | ) values (
15 | #{userId},
16 | #{agentId}
17 | )
18 |
19 |
20 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/jobx-rpc/src/test/java/NettyFileTest.java:
--------------------------------------------------------------------------------
1 | import org.junit.Test;
2 | import com.jobxhub.common.ext.ExtensionLoader;
3 | import com.jobxhub.common.job.*;
4 | import com.jobxhub.common.util.IdGenerator;
5 | import com.jobxhub.rpc.Client;
6 | import com.jobxhub.rpc.Server;
7 |
8 | import java.io.File;
9 |
10 | public class NettyFileTest {
11 |
12 |
13 | @Test
14 | public void server() {
15 | Server server = ExtensionLoader.load(Server.class);
16 | server.start(8089, null);
17 | }
18 |
19 | @Test
20 | public void client() throws Exception {
21 | Client client = ExtensionLoader.load(Client.class);
22 | Request request = new Request();
23 | request.setId(IdGenerator.getId());
24 | request.setAction(Action.UPLOAD);
25 | request.setRpcType(RpcType.SYNC);
26 | request.setHost("127.0.0.1");
27 | request.setPort(8089);
28 | File file = new File("/Users/benjobs/movie/盗梦空间.mkv");
29 | RequestFile requestFile = new RequestFile(file);
30 | requestFile.setSavePath("/Users/benjobs/Desktop");
31 | request.setUploadFile(requestFile);
32 | Response response = client.sentSync(request);
33 | System.out.println(response.getAction());
34 |
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/bootstrap/Launcher.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.bootstrap;
22 |
23 |
24 | import com.jobxhub.common.ext.SPI;
25 |
26 | /**
27 | * @author benjobs
28 | */
29 | @SPI
30 | public interface Launcher {
31 |
32 | void start(boolean devMode, int port) throws Exception;
33 |
34 | void stop();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/dao/ConfigDao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.dao;
22 |
23 | import com.jobxhub.server.domain.ConfigBean;
24 |
25 | import java.util.List;
26 |
27 | public interface ConfigDao {
28 |
29 | List getConfig();
30 |
31 | void update(ConfigBean configBean);
32 |
33 | String getExecUser();
34 | }
35 |
--------------------------------------------------------------------------------
/jobx-registry/src/main/java/com/jobxhub/registry/api/NotifyListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.registry.api;
22 |
23 |
24 | import com.jobxhub.registry.URL;
25 |
26 | import java.util.List;
27 |
28 | /**
29 | * @author benjobs
30 | */
31 | public interface NotifyListener {
32 |
33 | /**
34 | * 当收到服务变更通知时触发。
35 | */
36 | void notify(List urls);
37 |
38 | }
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/ObjectOutput.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 |
23 | package com.jobxhub.common.serialize;
24 |
25 | import java.io.IOException;
26 |
27 | /**
28 | * Object output.
29 | */
30 | public interface ObjectOutput extends DataOutput {
31 |
32 | /**
33 | * write object.
34 | *
35 | * @param obj object.
36 | */
37 | void writeObject(Object obj) throws IOException;
38 |
39 | }
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/kryo/utils/PrototypeKryoFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.serialize.kryo.utils;
23 |
24 | import com.esotericsoftware.kryo.Kryo;
25 |
26 | public class PrototypeKryoFactory extends AbstractKryoFactory {
27 |
28 | @Override
29 | public void returnKryo(Kryo kryo) {
30 | // do nothing
31 | }
32 |
33 | public Kryo getKryo() {
34 | return create();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/jobx-server/src/main/resources/app-websocket.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/controller/MonitorController.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.server.controller;
23 |
24 |
25 | import org.springframework.stereotype.Controller;
26 | import org.springframework.web.bind.annotation.RequestMapping;
27 |
28 |
29 | @Controller
30 | @RequestMapping("monitor")
31 | public class MonitorController {
32 |
33 | @RequestMapping("druid.htm")
34 | public String view() {
35 | return "/monitor/druid";
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/jobx-server/src/main/resources/mapper/ConfigDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
22 | update t_config
23 | set
24 | config_val = #{configVal},
25 | comment = #{comment}
26 | where config_key = #{configKey}
27 |
28 | and 1=2
29 |
30 |
31 |
32 |
37 |
38 |
--------------------------------------------------------------------------------
/jobx-server/src/main/webapp/WEB-INF/view/notice/info.jsp:
--------------------------------------------------------------------------------
1 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
2 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
3 | <%@ taglib prefix="cron" uri="http://www.jobx.org"%>
4 | <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
5 | <%
6 | String port = request.getServerPort() == 80 ? "" : (":"+request.getServerPort());
7 | String path = request.getContextPath().replaceAll("/$","");
8 | String contextPath = request.getScheme()+"://"+request.getServerName()+port+path;
9 | pageContext.setAttribute("contextPath",contextPath);
10 | %>
11 |
12 |
13 |
14 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/ext/SPI.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.common.ext;
22 |
23 | import java.lang.annotation.*;
24 |
25 |
26 | /**
27 | * 十步杀一人 千里不留行
28 | *
29 | * 事了拂衣去 深藏身与名
30 | *
31 | * 扩展点以Key=扩展点实例的全类名的方式在META-INF.jobx里定义
32 | * 默认的扩展点以"扩展点实例的全类名"呈现,不用Key
33 | */
34 | @Documented
35 | @Retention(RetentionPolicy.RUNTIME)
36 | @Target({ElementType.TYPE})
37 | public @interface SPI {
38 |
39 | /**
40 | * 缺省扩展点名。
41 | */
42 | String value() default "";
43 |
44 | }
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/util/NamedThreadFactory.java:
--------------------------------------------------------------------------------
1 | package com.jobxhub.common.util;
2 |
3 |
4 | import java.util.concurrent.ThreadFactory;
5 | import java.util.concurrent.atomic.AtomicInteger;
6 |
7 | public class NamedThreadFactory implements ThreadFactory {
8 | private static final AtomicInteger POOL_SEQ = new AtomicInteger(1);
9 |
10 | private final AtomicInteger mThreadNum = new AtomicInteger(1);
11 |
12 | private final String mPrefix;
13 |
14 | private final boolean mDaemo;
15 |
16 | private final ThreadGroup mGroup;
17 |
18 | public NamedThreadFactory() {
19 | this("pool-" + POOL_SEQ.getAndIncrement(), false);
20 | }
21 |
22 | public NamedThreadFactory(String prefix) {
23 | this(prefix, false);
24 | }
25 |
26 | public NamedThreadFactory(String prefix, boolean daemo) {
27 | mPrefix = prefix + "-thread-";
28 | mDaemo = daemo;
29 | SecurityManager s = System.getSecurityManager();
30 | mGroup = (s == null) ? Thread.currentThread().getThreadGroup() : s.getThreadGroup();
31 | }
32 |
33 | public Thread newThread(Runnable runnable) {
34 | String name = mPrefix + mThreadNum.getAndIncrement();
35 | Thread ret = new Thread(mGroup, runnable, name, 0);
36 | ret.setDaemon(mDaemo);
37 | return ret;
38 | }
39 |
40 | public ThreadGroup getThreadGroup() {
41 | return mGroup;
42 | }
43 | }
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/dao/UserAgentDao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.dao;
22 |
23 | import com.jobxhub.server.domain.UserAgentBean;
24 | import org.apache.ibatis.annotations.Param;
25 |
26 | import java.util.List;
27 |
28 | /**
29 | * 用户对哪些机器有权限....
30 | */
31 | public interface UserAgentDao {
32 |
33 | void delete(Long userId);
34 |
35 | void save(@Param("userId") Long userId, @Param("agentId") Long agentId);
36 |
37 | List getUserAgent(Long userId);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/jobx-registry/src/main/java/com/jobxhub/registry/zookeeper/curator/CuratorZookeeperTransporter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.registry.zookeeper.curator;
22 |
23 | import com.jobxhub.registry.URL;
24 | import com.jobxhub.registry.zookeeper.ZookeeperClient;
25 | import com.jobxhub.registry.zookeeper.ZookeeperTransporter;
26 |
27 | public class CuratorZookeeperTransporter implements ZookeeperTransporter {
28 |
29 | public ZookeeperClient connect(URL url) {
30 | return new CuratorZookeeperClient(url);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/jobx-registry/src/main/java/com/jobxhub/registry/zookeeper/zkclient/ZkclientZookeeperTransporter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.registry.zookeeper.zkclient;
22 |
23 |
24 | import com.jobxhub.registry.URL;
25 | import com.jobxhub.registry.zookeeper.ZookeeperClient;
26 | import com.jobxhub.registry.zookeeper.ZookeeperTransporter;
27 |
28 | public class ZkclientZookeeperTransporter implements ZookeeperTransporter {
29 |
30 | public ZookeeperClient connect(URL url) {
31 | return new ZkclientZookeeperClient(url);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/session/cached/CachedManager.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.session.cached;
22 |
23 | /**
24 | * @author benjobs
25 | */
26 | public interface CachedManager {
27 |
28 | void delete(Object key);
29 |
30 | T get(Object key, Class clazz);
31 |
32 | void set(Object key, Object object);
33 |
34 | /***
35 | * remove and return value
36 | * @param key
37 | * @param clazz
38 | * @param
39 | * @return
40 | */
41 | T remove(Object key, Class clazz);
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/jobx-server/src/main/webapp/static/js/xterm/addons/fullscreen/fullscreen.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Fullscreen addon for xterm.js
3 | * @module xterm/addons/fullscreen/fullscreen
4 | * @license MIT
5 | */
6 | (function (fullscreen) {
7 | if (typeof exports === 'object' && typeof module === 'object') {
8 | /*
9 | * CommonJS environment
10 | */
11 | module.exports = fullscreen(require('../../xterm'));
12 | } else if (typeof define == 'function') {
13 | /*
14 | * Require.js is available
15 | */
16 | define(['../../xterm'], fullscreen);
17 | } else {
18 | /*
19 | * Plain browser environment
20 | */
21 | fullscreen(window.Terminal);
22 | }
23 | })(function (Xterm) {
24 | var exports = {};
25 |
26 | /**
27 | * Toggle the given terminal's fullscreen mode.
28 | * @param {Xterm} term - The terminal to toggle full screen mode
29 | * @param {boolean} fullscreen - Toggle fullscreen on (true) or off (false)
30 | */
31 | exports.toggleFullScreen = function (term, fullscreen) {
32 | var fn;
33 |
34 | if (typeof fullscreen == 'undefined') {
35 | fn = (term.element.classList.contains('fullscreen')) ? 'remove' : 'add';
36 | } else if (!fullscreen) {
37 | fn = 'remove';
38 | } else {
39 | fn = 'add';
40 | }
41 |
42 | term.element.classList[fn]('fullscreen');
43 | };
44 |
45 | Xterm.prototype.toggleFullscreen = function (fullscreen) {
46 | exports.toggleFullScreen(this, fullscreen);
47 | };
48 |
49 | return exports;
50 | });
51 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/hessian2/Hessian2SerializerFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.common.serialize.hessian2;
22 |
23 | import com.caucho.hessian.io.SerializerFactory;
24 |
25 | public class Hessian2SerializerFactory extends SerializerFactory {
26 |
27 | public static final SerializerFactory SERIALIZER_FACTORY = new Hessian2SerializerFactory();
28 |
29 | private Hessian2SerializerFactory() {
30 | }
31 |
32 | @Override
33 | public ClassLoader getClassLoader() {
34 | return Thread.currentThread().getContextClassLoader();
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/jobx-server/src/main/webapp/static/js/highcharts/js/modules/no-data-to-display.js:
--------------------------------------------------------------------------------
1 | /*
2 | Highcharts JS v4.2.3 (2016-02-08)
3 | Plugin for displaying a message when there is no data visible in chart.
4 |
5 | (c) 2010-2016 Highsoft AS
6 | Author: Oystein Moseng
7 |
8 | License: www.highcharts.com/license
9 | */
10 | (function(a){typeof module==="object"&&module.exports?module.exports=a:a(Highcharts)})(function(a){function h(){return!!this.points.length}function d(){this.hasData()?this.hideNoData():this.showNoData()}var e=a.seriesTypes,c=a.Chart.prototype,f=a.getOptions(),g=a.extend,i=a.each;g(f.lang,{noData:"No data to display"});f.noData={position:{x:0,y:0,align:"center",verticalAlign:"middle"},attr:{},style:{fontWeight:"bold",fontSize:"12px",color:"#60606a"}};i(["pie","gauge","waterfall","bubble"],function(b){if(e[b])e[b].prototype.hasData=
11 | h});a.Series.prototype.hasData=function(){return this.visible&&this.dataMax!==void 0&&this.dataMin!==void 0};c.showNoData=function(b){var a=this.options,b=b||a.lang.noData,a=a.noData;if(!this.noDataLabel)this.noDataLabel=this.renderer.label(b,0,0,null,null,null,a.useHTML,null,"no-data").attr(a.attr).css(a.style).add(),this.noDataLabel.align(g(this.noDataLabel.getBBox(),a.position),!1,"plotBox")};c.hideNoData=function(){if(this.noDataLabel)this.noDataLabel=this.noDataLabel.destroy()};c.hasData=function(){for(var a=
12 | this.series,c=a.length;c--;)if(a[c].hasData()&&!a[c].options.isInternal)return!0;return!1};c.callbacks.push(function(b){a.addEvent(b,"load",d);a.addEvent(b,"redraw",d)})});
13 |
--------------------------------------------------------------------------------
/jobx-server/src/main/resources/config.properties:
--------------------------------------------------------------------------------
1 | jdbc.driver=com.mysql.jdbc.Driver
2 | jdbc.url=jdbc:mysql://localhost:3306/jobx?useUnicode=true&characterEncoding=utf8&useCursorFetch=true&autoReconnect=true&failOverReadOnly=false&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
3 | jdbc.username=root
4 | jdbc.password=123322242
5 |
6 | ##################################################################################################
7 | # server端是否集群(多个server)
8 | # 如果 jobx.cluster为true,则两种缓存实现(redis|memcached)任选其一进行配合(必须选一个)
9 | # 并且 jobx.cached 要写上对应的缓存实现(redis|memcached)
10 | # 如果为false,则 redis,memcached,和 jobx.cached 都不用管.
11 | ##################################################################################################
12 | jobx.cluster=false
13 | #(可选值: (redis|memcached)
14 | jobx.cached=memcached
15 |
16 | #redis 配置
17 | redis.host=10.20.10.111
18 | redis.password=123456
19 | redis.port=6379
20 | redis.dbIndex=0
21 | redis.expire=3000
22 | redis.maxIdle=300
23 | redis.maxActive=600
24 | redis.maxWait=1000
25 | redis.testOnBorrow=true
26 |
27 | #memcached 配置
28 | memcached.servers=127.0.0.1:11211
29 | memcached.protocol=BINARY
30 | memcached.opTimeout=1000
31 | memcached.expire=3000
32 | memcached.timeoutExceptionThreshold=1998
33 | memcached.locatorType=CONSISTENT
34 | memcached.failureMode=Redistribute
35 | memcached.useNagleAlgorithm=false
36 |
37 | #agent监控服务端口
38 | jobx.monitorPort=17502
39 | #zookepper注册中心
40 | jobx.registry=zookeeper://127.0.0.1:2181
41 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/util/IdGenerator.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.util;
23 |
24 | import java.io.IOException;
25 | import java.util.concurrent.atomic.AtomicInteger;
26 | import java.util.concurrent.atomic.AtomicLong;
27 |
28 | public class IdGenerator {
29 | private static final AtomicLong generator = new AtomicLong(0);
30 |
31 | public static Long getId() {
32 | return generator.incrementAndGet();
33 | }
34 |
35 | public static void main(String[] args) throws IOException {
36 | System.out.println(getId());
37 | System.in.read();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/jobx-registry/src/main/java/com/jobxhub/registry/api/Registry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.registry.api;
22 |
23 | /**
24 | * @author benjobs
25 | */
26 |
27 | import com.jobxhub.registry.zookeeper.ZookeeperClient;
28 |
29 | /**
30 | * @author benjobs
31 | */
32 | public interface Registry {
33 |
34 | boolean isAvailable();
35 |
36 | void recover() throws Exception;
37 |
38 | void destroy();
39 | /**
40 | * 注册数据
41 | */
42 | void register(String path, boolean ephemeral);
43 |
44 | /**
45 | * 取消注册.
46 | */
47 | void unRegister(String path);
48 |
49 | ZookeeperClient getClient();
50 | }
--------------------------------------------------------------------------------
/jobx-agent/src/main/java/com/jobxhub/agent/process/ProcessException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.agent.process;
23 |
24 | public class ProcessException extends RuntimeException {
25 |
26 | private static final long serialVersionUID = 1;
27 |
28 | private final int exitCode;
29 | private final String logSnippet;
30 |
31 | public ProcessException(final int exitCode, final String logSnippet) {
32 | this.exitCode = exitCode;
33 | this.logSnippet = logSnippet;
34 | }
35 |
36 | public int getExitCode() {
37 | return this.exitCode;
38 | }
39 |
40 | public String getLogSnippet() {
41 | return this.logSnippet;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/kryo/utils/ThreadLocalKryoFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.common.serialize.kryo.utils;
22 |
23 | import com.esotericsoftware.kryo.Kryo;
24 |
25 | public class ThreadLocalKryoFactory extends AbstractKryoFactory {
26 |
27 | private final ThreadLocal holder = new ThreadLocal() {
28 | @Override
29 | protected Kryo initialValue() {
30 | return create();
31 | }
32 | };
33 |
34 | @Override
35 | public void returnKryo(Kryo kryo) {
36 | // do nothing
37 | }
38 |
39 | public Kryo getKryo() {
40 | return holder.get();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/support/SerializableClassRegistry.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 |
23 | package com.jobxhub.common.serialize.support;
24 |
25 | import java.util.LinkedHashSet;
26 | import java.util.Set;
27 |
28 | public abstract class SerializableClassRegistry {
29 |
30 | private static final Set registrations = new LinkedHashSet();
31 |
32 | /**
33 | * only supposed to be called at startup time
34 | */
35 | public static void registerClass(Class clazz) {
36 | registrations.add(clazz);
37 | }
38 |
39 | public static Set getRegisteredClasses() {
40 | return registrations;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/util/internal/UnsafeLongFieldUpdater.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed under the Apache License, version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at:
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.jobxhub.common.util.internal;
18 |
19 | import sun.misc.Unsafe;
20 |
21 | import java.lang.reflect.Field;
22 |
23 | public class UnsafeLongFieldUpdater {
24 | private final long offset;
25 | private final Unsafe unsafe;
26 |
27 | UnsafeLongFieldUpdater(Unsafe unsafe, Class super U> tClass, String fieldName) throws NoSuchFieldException {
28 | Field field = tClass.getDeclaredField(fieldName);
29 | if (unsafe == null) {
30 | throw new NullPointerException("unsafe");
31 | }
32 | this.unsafe = unsafe;
33 | offset = unsafe.objectFieldOffset(field);
34 | }
35 |
36 | public void set(U obj, long newValue) {
37 | unsafe.putLong(obj, offset, newValue);
38 | }
39 |
40 | public long get(U obj) {
41 | return unsafe.getLong(obj, offset);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/util/internal/UnsafeIntegerFieldUpdater.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed under the Apache License, version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at:
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.jobxhub.common.util.internal;
18 |
19 | import sun.misc.Unsafe;
20 |
21 | import java.lang.reflect.Field;
22 |
23 | public class UnsafeIntegerFieldUpdater {
24 | private final long offset;
25 | private final Unsafe unsafe;
26 |
27 | UnsafeIntegerFieldUpdater(Unsafe unsafe, Class super U> tClass, String fieldName) throws NoSuchFieldException {
28 | Field field = tClass.getDeclaredField(fieldName);
29 | if (unsafe == null) {
30 | throw new NullPointerException("unsafe");
31 | }
32 | this.unsafe = unsafe;
33 | offset = unsafe.objectFieldOffset(field);
34 | }
35 |
36 | public void set(U obj, int newValue) {
37 | unsafe.putInt(obj, offset, newValue);
38 | }
39 |
40 | public int get(U obj) {
41 | return unsafe.getInt(obj, offset);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/jobx-server/src/main/webapp/static/js/highcharts/js/themes/grid-light.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Grid-light theme for Highcharts JS
3 | * @author Torstein Honsi
4 | */
5 |
6 | // Load the fonts
7 | Highcharts.createElement('link', {
8 | href: '//fonts.googleapis.com/css?family=Dosis:400,600',
9 | rel: 'stylesheet',
10 | type: 'text/css'
11 | }, null, document.getElementsByTagName('head')[0]);
12 |
13 | Highcharts.theme = {
14 | colors: ["#7cb5ec", "#f7a35c", "#90ee7e", "#7798BF", "#aaeeee", "#ff0066", "#eeaaee",
15 | "#55BF3B", "#DF5353", "#7798BF", "#aaeeee"],
16 | chart: {
17 | backgroundColor: null,
18 | style: {
19 | fontFamily: "Dosis, sans-serif"
20 | }
21 | },
22 | title: {
23 | style: {
24 | fontSize: '16px',
25 | fontWeight: 'bold',
26 | textTransform: 'uppercase'
27 | }
28 | },
29 | tooltip: {
30 | borderWidth: 0,
31 | backgroundColor: 'rgba(219,219,216,0.8)',
32 | shadow: false
33 | },
34 | legend: {
35 | itemStyle: {
36 | fontWeight: 'bold',
37 | fontSize: '13px'
38 | }
39 | },
40 | xAxis: {
41 | gridLineWidth: 1,
42 | labels: {
43 | style: {
44 | fontSize: '12px'
45 | }
46 | }
47 | },
48 | yAxis: {
49 | minorTickInterval: 'auto',
50 | title: {
51 | style: {
52 | textTransform: 'uppercase'
53 | }
54 | },
55 | labels: {
56 | style: {
57 | fontSize: '12px'
58 | }
59 | }
60 | },
61 | plotOptions: {
62 | candlestick: {
63 | lineColor: '#404048'
64 | }
65 | },
66 |
67 |
68 | // General
69 | background2: '#F0F0EA'
70 |
71 | };
72 |
73 | // Apply the theme
74 | Highcharts.setOptions(Highcharts.theme);
75 |
--------------------------------------------------------------------------------
/jobx-agent/assembly.xml:
--------------------------------------------------------------------------------
1 |
2 | ${project.version}
3 |
4 | tar.gz
5 |
6 |
7 |
8 | true
9 | lib
10 |
11 |
12 |
13 |
14 | src/assembly/bin
15 | bin
16 | 0755
17 |
18 |
19 | src/assembly/lib
20 | lib
21 | 0644
22 |
23 |
24 | src/assembly/native
25 | native
26 | 0644
27 |
28 |
29 | src/assembly/conf
30 | conf
31 | 0644
32 |
33 |
34 | src/assembly/logs
35 | logs
36 | 0644
37 |
38 |
39 | src/assembly/temp
40 | temp
41 | 0755
42 |
43 |
44 |
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/netty/idle/IdleServerHandler.java:
--------------------------------------------------------------------------------
1 | package com.jobxhub.rpc.netty.idle;
2 |
3 | import com.jobxhub.rpc.netty.idle.domain.IdleRequest;
4 | import com.jobxhub.rpc.netty.idle.domain.IdleResponse;
5 | import io.netty.channel.ChannelHandler;
6 | import io.netty.channel.ChannelHandlerContext;
7 | import io.netty.channel.SimpleChannelInboundHandler;
8 | import io.netty.handler.timeout.IdleStateEvent;
9 | import org.slf4j.Logger;
10 | import org.slf4j.LoggerFactory;
11 |
12 | import java.util.Date;
13 |
14 | /**
15 | * @author Autorun
16 | */
17 | @ChannelHandler.Sharable
18 | public class IdleServerHandler extends SimpleChannelInboundHandler {
19 |
20 | private final Logger logger = LoggerFactory.getLogger(getClass());
21 |
22 | @Override
23 | protected void channelRead0(ChannelHandlerContext ctx, IdleRequest msg) throws Exception {
24 | System.out.println(msg);
25 | }
26 |
27 | @Override
28 | public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
29 | if (!(evt instanceof IdleStateEvent)) {
30 | super.userEventTriggered(ctx, evt);
31 | return;
32 | }
33 | IdleStateEvent event = (IdleStateEvent) evt;
34 | String side = "RESPONSE";
35 | String remoteAddress = ctx.channel().remoteAddress().toString();
36 | Date currentDate = new Date();
37 | logger.debug("[JobX] Idle request, requestType: [{}], remoteInfo: [{}], eventType: [{}]",
38 | side,
39 | remoteAddress,
40 | event.state()
41 | );
42 | ctx.writeAndFlush(new IdleResponse().setEvent(event).setRemoteAddr(remoteAddress).setSide(side).setTime(currentDate)); }
43 | }
44 |
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/netty/idle/IdleClientHandler.java:
--------------------------------------------------------------------------------
1 | package com.jobxhub.rpc.netty.idle;
2 |
3 | import com.jobxhub.rpc.netty.idle.domain.IdleRequest;
4 | import com.jobxhub.rpc.netty.idle.domain.IdleResponse;
5 | import io.netty.channel.ChannelHandler;
6 | import io.netty.channel.ChannelHandlerContext;
7 | import io.netty.channel.SimpleChannelInboundHandler;
8 | import io.netty.handler.timeout.IdleStateEvent;
9 | import org.slf4j.Logger;
10 | import org.slf4j.LoggerFactory;
11 |
12 | import java.util.Date;
13 |
14 | /**
15 | * @author Autorun
16 | */
17 | @ChannelHandler.Sharable
18 | public class IdleClientHandler extends SimpleChannelInboundHandler {
19 |
20 | private final Logger logger = LoggerFactory.getLogger(getClass());
21 |
22 | @Override
23 | protected void channelRead0(ChannelHandlerContext ctx, IdleResponse msg) throws Exception {
24 | System.out.println(msg);
25 | }
26 |
27 | @Override
28 | public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
29 | if (!(evt instanceof IdleStateEvent)) {
30 | super.userEventTriggered(ctx, evt);
31 | return;
32 | }
33 | IdleStateEvent event = (IdleStateEvent) evt;
34 | String side = "REQUEST";
35 | String remoteAddress = ctx.channel().remoteAddress().toString();
36 | Date currentDate = new Date();
37 | logger.debug("[JobX] Idle request, requestType: [{}], remoteInfo: [{}], eventType: [{}]",
38 | side,
39 | remoteAddress,
40 | event.state()
41 | );
42 | ctx.writeAndFlush(new IdleRequest().setEvent(event).setRemoteAddr(remoteAddress).setSide(side).setTime(currentDate));
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/jobx-agent/src/assembly/bin/startup.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | @REM
3 | @REM Copyright (c) 2015 The JobX Project
4 | @REM
5 | @REM Licensed to the Apache Software Foundation (ASF) under one
6 | @REM or more contributor license agreements. See the NOTICE file
7 | @REM distributed with this work for additional information
8 | @REM regarding copyright ownership. The ASF licenses this file
9 | @REM to you under the Apache License, Version 2.0 (the
10 | @REM "License"); you may not use this file except in compliance
11 | @REM with the License. You may obtain a copy of the License at
12 | @REM
13 | @REM http://www.apache.org/licenses/LICENSE-2.0
14 | @REM
15 | @REM Unless required by applicable law or agreed to in writing,
16 | @REM software distributed under the License is distributed on an
17 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | @REM KIND, either express or implied. See the License for the
19 | @REM specific language governing permissions and limitations
20 | @REM under the License.
21 | @REM
22 | @REM ---------------------------------------------------------------------------
23 | @REM Start script for the JOBX agent
24 | @REM ---------------------------------------------------------------------------
25 |
26 | setlocal
27 |
28 | @REM Guess JOBX_HOME if not defined
29 | set WORK_DIR=%~dp0
30 | cd "%WORK_DIR%.."
31 | set JOBX_HOME=%cd%
32 | set EXECUTABLE=%JOBX_HOME%\bin\jobx.bat
33 |
34 | if exist "%EXECUTABLE%" goto okExec
35 | echo Cannot find "%EXECUTABLE%"
36 | echo This file is needed to run this program
37 | goto exit
38 |
39 | :okExec
40 | call "%EXECUTABLE%" start
41 |
42 | :end
43 |
44 | :exit
45 | exit 1
46 |
47 | :end
48 | exit 0
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/dao/LogDao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.dao;
22 |
23 |
24 | import com.jobxhub.server.domain.LogBean;
25 | import com.jobxhub.server.tag.PageBean;
26 | import org.apache.ibatis.annotations.Param;
27 |
28 | import java.util.List;
29 | import java.util.Map;
30 |
31 | public interface LogDao {
32 |
33 | LogBean getById(@Param("logId") Long logId);
34 |
35 | List getByPageBean(@Param("pager") PageBean pageBean);
36 |
37 | int getCount(@Param("filter") Map filter);
38 |
39 | List getUnRead(Long userId);
40 |
41 | Integer getUnReadCount(Long userId);
42 |
43 | void updateRead(Long logId);
44 |
45 | void save(LogBean log);
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/jobx-agent/src/assembly/bin/shutdown.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | @REM
3 | @REM Copyright (c) 2015 The JobX Project
4 | @REM
5 | @REM Licensed to the Apache Software Foundation (ASF) under one
6 | @REM or more contributor license agreements. See the NOTICE file
7 | @REM distributed with this work for additional information
8 | @REM regarding copyright ownership. The ASF licenses this file
9 | @REM to you under the Apache License, Version 2.0 (the
10 | @REM "License"); you may not use this file except in compliance
11 | @REM with the License. You may obtain a copy of the License at
12 | @REM
13 | @REM http://www.apache.org/licenses/LICENSE-2.0
14 | @REM
15 | @REM Unless required by applicable law or agreed to in writing,
16 | @REM software distributed under the License is distributed on an
17 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 | @REM KIND, either express or implied. See the License for the
19 | @REM specific language governing permissions and limitations
20 | @REM under the License.
21 | @REM
22 | @REM ---------------------------------------------------------------------------
23 | @REM Stop script for the JOBX agent
24 | @REM ---------------------------------------------------------------------------
25 |
26 | setlocal
27 |
28 | @REM Guess JOBX_HOME if not defined
29 | set WORK_DIR=%~dp0
30 | cd "%WORK_DIR%.."
31 | set JOBX_HOME=%cd%
32 | set EXECUTABLE=%JOBX_HOME%\bin\jobx.bat
33 |
34 | if exist "%EXECUTABLE%" goto okExec
35 | echo Cannot find "%EXECUTABLE%"
36 | echo This file is needed to run this program
37 | goto exit
38 |
39 | :okExec
40 | call "%EXECUTABLE%" stop
41 | goto end
42 |
43 | :exit
44 | exit /b 1
45 |
46 | :end
47 | exit /b 0
48 |
--------------------------------------------------------------------------------
/jobx-rpc/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | jobx
7 | com.jobxhub
8 | 1.2.0-RELEASE
9 |
10 | 4.0.0
11 | jobx-rpc
12 |
13 |
14 |
15 | org.apache.maven.plugins
16 | maven-compiler-plugin
17 |
18 | 7
19 | 7
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | com.jobxhub
29 | jobx-common
30 |
31 |
32 |
33 | io.netty
34 | netty-all
35 |
36 |
37 |
38 | org.apache.mina
39 | mina-core
40 |
41 |
42 |
43 | org.apache.zookeeper
44 | zookeeper
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/exception/InvalidException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.exception;
23 |
24 | /**
25 | * 参数异常
26 | *
27 | * @author wanghuajie
28 | */
29 | public class InvalidException extends BasicException {
30 |
31 | private static final long serialVersionUID = 2513495667924595876L;
32 |
33 | public InvalidException() {
34 | super();
35 | }
36 |
37 | public InvalidException(String msg) {
38 | super(msg);
39 | }
40 |
41 | public InvalidException(Throwable nestedThrowable) {
42 | super(nestedThrowable);
43 | }
44 |
45 | public InvalidException(String msg, Throwable nestedThrowable) {
46 | super(msg, nestedThrowable);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/exception/UnknownException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.common.exception;
22 |
23 | /**
24 | * 未知异常
25 | *
26 | * @author wanghuajie 2012.8.23
27 | */
28 | public class UnknownException extends BasicException {
29 |
30 | private static final long serialVersionUID = 9108301934211924250L;
31 |
32 | public UnknownException() {
33 | super();
34 | }
35 |
36 | public UnknownException(String msg) {
37 | super(msg);
38 | }
39 |
40 | public UnknownException(Throwable nestedThrowable) {
41 | super(nestedThrowable);
42 | }
43 |
44 | public UnknownException(String msg, Throwable nestedThrowable) {
45 | super(msg, nestedThrowable);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/exception/ParameterException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.exception;
23 |
24 | /**
25 | * 参数异常
26 | *
27 | * @author wanghuajie
28 | */
29 | public class ParameterException extends BasicException {
30 |
31 | private static final long serialVersionUID = 2513495667924595876L;
32 |
33 | public ParameterException() {
34 | super();
35 | }
36 |
37 | public ParameterException(String msg) {
38 | super(msg);
39 | }
40 |
41 | public ParameterException(Throwable nestedThrowable) {
42 | super(nestedThrowable);
43 | }
44 |
45 | public ParameterException(String msg, Throwable nestedThrowable) {
46 | super(msg, nestedThrowable);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/kryo/utils/PooledKryoFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.serialize.kryo.utils;
23 |
24 | import com.esotericsoftware.kryo.Kryo;
25 | import com.esotericsoftware.kryo.pool.KryoPool;
26 |
27 | public class PooledKryoFactory extends AbstractKryoFactory {
28 |
29 | private KryoPool pool;
30 |
31 | public PooledKryoFactory() {
32 | // Build pool with SoftReferences enabled (optional)
33 | pool = new KryoPool.Builder(this).softReferences().build();
34 | }
35 |
36 | @Override
37 | public Kryo getKryo() {
38 | return pool.borrow();
39 | }
40 |
41 | @Override
42 | public void returnKryo(Kryo kryo) {
43 | pool.release(kryo);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/jobx-registry/src/main/java/com/jobxhub/registry/zookeeper/ZookeeperClient.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.registry.zookeeper;
23 |
24 |
25 | import com.jobxhub.common.ext.SPI;
26 |
27 | import java.util.List;
28 |
29 | @SPI
30 | public interface ZookeeperClient {
31 |
32 | void create(String path, boolean ephemeral);
33 |
34 | void delete(String path);
35 |
36 | List getChildren(String path);
37 |
38 | List addChildListener(String path, ChildListener listener);
39 |
40 | void removeChildListener(String path, ChildListener listener);
41 |
42 | void addStateListener(StateListener listener);
43 |
44 | void removeStateListener(StateListener listener);
45 |
46 | boolean isConnected();
47 |
48 | void close();
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/netty/idle/domain/IdleRequest.java:
--------------------------------------------------------------------------------
1 | package com.jobxhub.rpc.netty.idle.domain;
2 |
3 | import io.netty.handler.timeout.IdleStateEvent;
4 |
5 | import java.util.Date;
6 | import java.util.Objects;
7 |
8 | /**
9 | * @author Autorun
10 | */
11 | public class IdleRequest {
12 |
13 | private String remoteAddr;
14 |
15 | private IdleStateEvent event;
16 |
17 | private String side;
18 |
19 | private Date time;
20 |
21 | public IdleRequest setRemoteAddr(String remoteAddr) {
22 | this.remoteAddr = remoteAddr;
23 | return this;
24 | }
25 |
26 | public IdleRequest setEvent(IdleStateEvent event) {
27 | this.event = event;
28 | return this;
29 | }
30 |
31 | public IdleRequest setSide(String side) {
32 | this.side = side;
33 | return this;
34 | }
35 |
36 | public IdleRequest setTime(Date time) {
37 | this.time = time;
38 | return this;
39 | }
40 |
41 | @Override
42 | public boolean equals(Object o) {
43 | if (this == o) {
44 | return true;
45 | }
46 | if (o == null || getClass() != o.getClass()) {
47 | return false;
48 | }
49 | IdleRequest that = (IdleRequest) o;
50 | return Objects.equals(remoteAddr, that.remoteAddr) &&
51 | Objects.equals(event, that.event) &&
52 | Objects.equals(side, that.side) &&
53 | Objects.equals(time, that.time);
54 | }
55 |
56 | @Override
57 | public int hashCode() {
58 | return Objects.hash(remoteAddr, event, side, time);
59 | }
60 |
61 | @Override
62 | public String toString() {
63 | return "IdleRequest{" +
64 | "remoteAddr='" + remoteAddr + '\'' +
65 | ", event=" + event +
66 | ", side='" + side + '\'' +
67 | ", time=" + time +
68 | '}';
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/netty/idle/domain/IdleResponse.java:
--------------------------------------------------------------------------------
1 | package com.jobxhub.rpc.netty.idle.domain;
2 |
3 | import io.netty.handler.timeout.IdleStateEvent;
4 |
5 | import java.util.Date;
6 | import java.util.Objects;
7 |
8 | /**
9 | * @author Autorun
10 | */
11 | public class IdleResponse {
12 |
13 | private String remoteAddr;
14 |
15 | private IdleStateEvent event;
16 |
17 | private String side;
18 |
19 | private Date time;
20 |
21 | public IdleResponse setRemoteAddr(String remoteAddr) {
22 | this.remoteAddr = remoteAddr;
23 | return this;
24 | }
25 |
26 | public IdleResponse setEvent(IdleStateEvent event) {
27 | this.event = event;
28 | return this;
29 | }
30 |
31 | public IdleResponse setSide(String side) {
32 | this.side = side;
33 | return this;
34 | }
35 |
36 | public IdleResponse setTime(Date time) {
37 | this.time = time;
38 | return this;
39 | }
40 |
41 | @Override
42 | public boolean equals(Object o) {
43 | if (this == o) {
44 | return true;
45 | }
46 | if (o == null || getClass() != o.getClass()) {
47 | return false;
48 | }
49 | IdleResponse that = (IdleResponse) o;
50 | return Objects.equals(remoteAddr, that.remoteAddr) &&
51 | Objects.equals(event, that.event) &&
52 | Objects.equals(side, that.side) &&
53 | Objects.equals(time, that.time);
54 | }
55 |
56 | @Override
57 | public int hashCode() {
58 | return Objects.hash(remoteAddr, event, side, time);
59 | }
60 |
61 | @Override
62 | public String toString() {
63 | return "IdleResponse{" +
64 | "remoteAddr='" + remoteAddr + '\'' +
65 | ", event=" + event +
66 | ", side='" + side + '\'' +
67 | ", time=" + time +
68 | '}';
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/jobx-registry/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | jobx
7 | com.jobxhub
8 | 1.2.0-RELEASE
9 |
10 | 4.0.0
11 | jobx-registry
12 |
13 |
14 |
15 | org.apache.maven.plugins
16 | maven-compiler-plugin
17 |
18 | 7
19 | 7
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | com.jobxhub
29 | jobx-common
30 |
31 |
32 |
33 |
34 | org.apache.zookeeper
35 | zookeeper
36 |
37 |
38 |
39 | com.101tec
40 | zkclient
41 |
42 |
43 |
44 | org.apache.curator
45 | curator-framework
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/session/wrapper/HttpServletRequestSessionWrapper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.session.wrapper;
22 |
23 |
24 | import javax.servlet.http.HttpServletRequest;
25 | import javax.servlet.http.HttpSession;
26 |
27 | public class HttpServletRequestSessionWrapper extends javax.servlet.http.HttpServletRequestWrapper {
28 |
29 | private HttpSession session;
30 |
31 | public HttpServletRequestSessionWrapper(HttpServletRequest request, HttpSession session) {
32 | super(request);
33 | this.session = session;
34 | }
35 |
36 | @Override
37 | public HttpSession getSession(boolean create) {
38 | return session;
39 | }
40 |
41 | @Override
42 | public HttpSession getSession() {
43 | return session;
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/jobx-rpc/src/main/java/com/jobxhub/rpc/Invoker.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.rpc;
23 |
24 | import com.jobxhub.common.job.Request;
25 | import com.jobxhub.common.job.Response;
26 |
27 | /**
28 | * @author benjobs
29 | */
30 | public interface Invoker {
31 |
32 | /**
33 | * 同步阻塞调用
34 | * @param request
35 | * @return
36 | * @throws Exception
37 | */
38 | Response sentSync(Request request) throws Exception;
39 |
40 | /**
41 | * 单向调用
42 | * @param request
43 | * @throws Exception
44 | */
45 | void sentOneWay(Request request) throws Exception;
46 |
47 | /**
48 | * 异步非阻塞,通知回调方式调用
49 | * @param request
50 | * @param callback
51 | * @throws Exception
52 | */
53 | void sentAsync(Request request, InvokeCallback callback) throws Exception;
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/jobx-server/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | ### set log levels ###
2 | log4j.rootLogger=INFO , console , DEBUG , error
3 | ### console ###
4 | log4j.appender.console=org.apache.log4j.ConsoleAppender
5 | log4j.appender.console.Target=System.out
6 | log4j.appender.console.layout=org.apache.log4j.PatternLayout
7 | log4j.appender.console.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%p]-[%c] %m%n
8 |
9 | ### log file ###
10 | log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender
11 | log4j.appender.debug.File=${catalina.home}/logs/jobx.out
12 | log4j.appender.debug.Append=true
13 | log4j.appender.debug.Threshold=INFO
14 | log4j.appender.debug.layout=org.apache.log4j.PatternLayout
15 | log4j.appender.debug.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%p]-[%c] %m%n
16 | ### exception ###
17 | log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
18 | log4j.appender.error.File=${catalina.home}/logs/jobx.err
19 | log4j.appender.error.Append=true
20 | log4j.appender.error.Threshold=ERROR
21 | log4j.appender.error.layout=org.apache.log4j.PatternLayout
22 | log4j.appender.error.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} [%p]-[%c] %m%n
23 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
24 | log4j.appender.stdout.Target=System.out
25 | log4j.appender.stdout.File=${catalina.home}/logs/jobx.out
26 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
27 | log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %l %c%n%p: %m%n
28 | ### druid sql ###
29 | log4j.logger.druid.sql=warn,stdout
30 | log4j.logger.druid.sql.DataSource=warn,stdout
31 | log4j.logger.druid.sql.Connection=warn,stdout
32 | log4j.logger.druid.sql.Statement=warn,stdout
33 | log4j.logger.druid.sql.ResultSet=warn,stdout
34 |
35 | #mybatis
36 | log4j.logger.com.jobxhub.server.dao=DEBUG
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/graph/Node.java:
--------------------------------------------------------------------------------
1 | package com.jobxhub.common.graph;
2 | /**
3 | * @Package org.opencron.common.graph
4 | * @Title: Node
5 | * @author hitechr
6 | * @date 2018/4/11 13:06
7 | * @version V1.0
8 | */
9 |
10 | /**
11 | * @Descriptions: 顶点数据元素
12 | */
13 | public class Node {
14 | private T val;
15 | private int pathIn = 0; // 入链路数量
16 | private int level;//节点的层次
17 | public Node(T val) {
18 | this.val = val;
19 | }
20 |
21 | public int getLevel() {
22 | return level;
23 | }
24 |
25 | public void setLevel(int level) {
26 | this.level = level;
27 | }
28 |
29 | public int getPathIn() {
30 | return pathIn;
31 | }
32 |
33 | public void setPathIn(int pathIn) {
34 | this.pathIn = pathIn;
35 | }
36 |
37 | public void pathIn(){
38 | this.setPathIn(this.getPathIn()+1);
39 | }
40 | public void levelIn(){
41 | this.setLevel(this.getLevel()+1);
42 | }
43 |
44 |
45 | public T getVal() {
46 | return val;
47 | }
48 |
49 | public void setVal(T val) {
50 | this.val = val;
51 | }
52 |
53 |
54 | @Override
55 | public boolean equals(Object o) {
56 | if (this == o) return true;
57 | if (o == null || getClass() != o.getClass()) return false;
58 |
59 | Node> node = (Node>) o;
60 |
61 | return val.equals(node.val);
62 | }
63 |
64 | @Override
65 | public int hashCode() {
66 | return val.hashCode();
67 | }
68 |
69 | @Override
70 | public String toString() {
71 | return "Node{" +
72 | "val=" + val +
73 | ", pathIn=" + pathIn +
74 | ", level=" + level +
75 | '}';
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/kryo/utils/KryoUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 |
23 | package com.jobxhub.common.serialize.kryo.utils;
24 |
25 | import com.esotericsoftware.kryo.Kryo;
26 |
27 | /**
28 | * The kryo utils used by dubbo
29 | *
30 | * @since 2.6.0
31 | */
32 | public class KryoUtils {
33 | private static AbstractKryoFactory kryoFactory = new ThreadLocalKryoFactory();
34 |
35 | public static Kryo get() {
36 | return kryoFactory.getKryo();
37 | }
38 |
39 | public static void release(Kryo kryo) {
40 | kryoFactory.returnKryo(kryo);
41 | }
42 |
43 | public static void register(Class> clazz) {
44 | kryoFactory.registerClass(clazz);
45 | }
46 |
47 | public static void setRegistrationRequired(boolean registrationRequired) {
48 | kryoFactory.setRegistrationRequired(registrationRequired);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/support/SshUserInfo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.server.support;
23 |
24 | import com.jcraft.jsch.UserInfo;
25 |
26 | public class SshUserInfo implements UserInfo {
27 | //private String passphrase = null;
28 |
29 | public SshUserInfo() {
30 | //this.passphrase = passphrase;
31 | }
32 |
33 | public String getPassphrase() {
34 | return null;//passphrase;
35 | }
36 |
37 | public String getPassword() {
38 | return null;
39 | }
40 |
41 | public boolean promptPassphrase(String s) {
42 | return true;
43 | }
44 |
45 | public boolean promptPassword(String s) {
46 | return true;
47 | }
48 |
49 | public boolean promptYesNo(String s) {
50 | return true;
51 | }
52 |
53 | public void showMessage(String s) {
54 | System.out.println(s);
55 | }
56 | }
--------------------------------------------------------------------------------
/jobx-agent/src/assembly/conf/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=info,console,debug, error
2 | # Print only messages of level ERROR or above in the package noModule.
3 | log4j.logger.noModule=FATAL
4 | log4j.additivity.org.apache=true
5 | ############################################################
6 | # CONSOLE #
7 | ############################################################
8 | log4j.appender.console=org.apache.log4j.ConsoleAppender
9 | log4j.appender.console.Threshold=INFO
10 | log4j.appender.console.ImmediateFlush=true
11 | log4j.appender.console.layout=org.apache.log4j.PatternLayout
12 | log4j.appender.console.layout.ConversionPattern=[%-5p] %d(%r) --> [%t] %l: %m %x %n
13 | ############################################################
14 | # DEBUG #
15 | ############################################################
16 | log4j.appender.debug=org.apache.log4j.DailyRollingFileAppender
17 | log4j.appender.debug.File=${jobx.home}/logs/jobx.out
18 | log4j.appender.debug.Append=true
19 | log4j.appender.debug.Threshold=DEBUG
20 | log4j.appender.debug.layout=org.apache.log4j.PatternLayout
21 | log4j.appender.debug.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
22 | ############################################################
23 | # ERROR #
24 | ############################################################
25 | log4j.appender.error=org.apache.log4j.DailyRollingFileAppender
26 | log4j.appender.error.File=${jobx.home}/logs/error.out
27 | log4j.appender.error.layout=org.apache.log4j.PatternLayout
28 | log4j.appender.error.layout.ConversionPattern=[%d]-%-5p (%F:%L)|%m%n
29 | log4j.appender.error.DatePattern='-'yyyy-MM-dd'.log'
30 | log4j.appender.error.Threshold=ERROR
31 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/ObjectInput.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 |
23 | package com.jobxhub.common.serialize;
24 |
25 | import java.io.IOException;
26 | import java.lang.reflect.Type;
27 |
28 | /**
29 | * Object input.
30 | */
31 | public interface ObjectInput extends DataInput {
32 |
33 | /**
34 | * read object.
35 | *
36 | * @return object.
37 | */
38 | Object readObject() throws IOException, ClassNotFoundException;
39 |
40 | /**
41 | * read object.
42 | *
43 | * @param cls object type.
44 | * @return object.
45 | */
46 | T readObject(Class cls) throws IOException, ClassNotFoundException;
47 |
48 | /**
49 | * read object.
50 | *
51 | * @param cls object type.
52 | * @return object.
53 | */
54 | T readObject(Class cls, Type type) throws IOException, ClassNotFoundException;
55 |
56 | }
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/dao/UserDao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.dao;
22 |
23 | import com.jobxhub.server.domain.UserBean;
24 | import com.jobxhub.server.tag.PageBean;
25 | import org.apache.ibatis.annotations.Param;
26 |
27 | import java.util.List;
28 | import java.util.Map;
29 |
30 | public interface UserDao {
31 |
32 | List getByPageBean(@Param("pager") PageBean pageBean);
33 |
34 | int getCount(@Param("filter") Map filter);
35 |
36 | void save(UserBean user);
37 |
38 | UserBean getById(Long id);
39 |
40 | void update(UserBean user);
41 |
42 | UserBean getByName(String userName);
43 |
44 | void updatePassword(@Param("userId") Long userId, @Param("password") String password);
45 |
46 | void uploadImg(@Param("userId") Long userId, @Param("headerPic") byte[] headerPic);
47 |
48 | String getExecUser(@Param("userId") Long userId);
49 | }
50 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/job/Action.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 |
23 | package com.jobxhub.common.job;
24 |
25 | public enum Action {
26 | PING(0),
27 | PATH(1),
28 | LISTPATH(2),
29 | MONITOR(3),
30 | EXECUTE(4),
31 | PASSWORD(5),
32 | KILL(6),
33 | PROXY(7),
34 | MACID(8),
35 | RESTART(9),
36 | UPLOAD(10);
37 |
38 | private final int value;
39 |
40 | Action(int value) {
41 | this.value = value;
42 | }
43 |
44 | /**
45 | * Get the integer value of this enum value, as defined in the Thrift IDL.
46 | */
47 | public int getValue() {
48 | return value;
49 | }
50 |
51 |
52 | public static Action findByName(String name) {
53 | for (Action action : Action.values()) {
54 | if (action.name().equalsIgnoreCase(name)) {
55 | return action;
56 | }
57 | }
58 | return null;
59 | }
60 |
61 | }
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/java/CompactedObjectOutputStream.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.common.serialize.java;
22 |
23 | import java.io.IOException;
24 | import java.io.ObjectOutputStream;
25 | import java.io.ObjectStreamClass;
26 | import java.io.OutputStream;
27 |
28 | /**
29 | * Compacted java object output stream.
30 | */
31 | public class CompactedObjectOutputStream extends ObjectOutputStream {
32 | public CompactedObjectOutputStream(OutputStream out) throws IOException {
33 | super(out);
34 | }
35 |
36 | @Override
37 | protected void writeClassDescriptor(ObjectStreamClass desc) throws IOException {
38 | Class> clazz = desc.forClass();
39 | if (clazz.isPrimitive() || clazz.isArray()) {
40 | write(0);
41 | super.writeClassDescriptor(desc);
42 | } else {
43 | write(1);
44 | writeUTF(desc.getName());
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/dao/TerminalDao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.dao;
22 |
23 | import com.jobxhub.server.domain.TerminalBean;
24 | import com.jobxhub.server.tag.PageBean;
25 | import org.apache.ibatis.annotations.Param;
26 |
27 | import java.util.Date;
28 | import java.util.List;
29 | import java.util.Map;
30 |
31 | public interface TerminalDao {
32 |
33 | List getByPageBean(@Param("pager") PageBean pageBean);
34 |
35 | List getByUser(Long userId);
36 |
37 | TerminalBean getById(Long id);
38 |
39 | int getCount(@Param("filter") Map filter);
40 |
41 | void save(TerminalBean terminalBean);
42 |
43 | void update(TerminalBean terminalBean);
44 |
45 | void updateLoginTime(@Param("id")Long id,@Param("loginTime")Date date);
46 |
47 | void updateTheme(@Param("id") Long id,@Param("theme") String theme);
48 |
49 | void delete(Long id);
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/jobx-common/src/test/java/SyncTest.java:
--------------------------------------------------------------------------------
1 |
2 | import org.apache.commons.exec.*;
3 |
4 | import java.util.Timer;
5 | import java.util.TimerTask;
6 |
7 |
8 | /**
9 | * Created by benjobs on 2016/9/10.
10 | */
11 | public class SyncTest {
12 |
13 |
14 | public static void main(String[] args) throws Exception {
15 |
16 | final CommandLine cmdLine = CommandLine.parse("C:\\Developer\\workspace\\bat\\hello.bat");
17 | final ExecuteWatchdog watchdog = new ExecuteWatchdog(Integer.MAX_VALUE);
18 |
19 | final Timer timer = new Timer();
20 |
21 | final DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler() {
22 | @Override
23 | public void onProcessComplete(int exitValue) {
24 | super.onProcessComplete(exitValue);
25 | watchdog.stop();
26 | timer.cancel();
27 | }
28 |
29 | @Override
30 | public void onProcessFailed(ExecuteException e) {
31 | super.onProcessFailed(e);
32 | watchdog.stop();
33 | timer.cancel();
34 | }
35 | };
36 |
37 | DefaultExecutor executor = new DefaultExecutor();
38 |
39 | executor.setWatchdog(watchdog);
40 |
41 | timer.schedule(new TimerTask() {
42 | @Override
43 | public void run() {
44 | //超时,kill...
45 | if (watchdog.isWatching()) {
46 | watchdog.stop();
47 | System.out.println(watchdog.isWatching());
48 | timer.cancel();
49 | System.out.println("kill....");
50 | }
51 | }
52 | }, 5 * 1000);
53 |
54 | executor.execute(cmdLine, resultHandler);
55 | System.out.println("dog is running?" + watchdog.isWatching());
56 |
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/event/AlarmListener.java:
--------------------------------------------------------------------------------
1 | package com.jobxhub.server.event;
2 | /**
3 | * @Package com.jobxhub.server.event
4 | * @Title: AlarmListener
5 | * @author hitechr
6 | * @date 2018/6/11 9:01
7 | * @version V1.0
8 | */
9 |
10 | import com.jobxhub.common.job.Alarm;
11 | import com.jobxhub.server.alarm.AlarmMessage;
12 | import com.jobxhub.server.alarm.AlarmNoticeFacory;
13 | import com.jobxhub.server.alarm.SendNotice;
14 | import org.springframework.context.ApplicationListener;
15 | import org.springframework.scheduling.annotation.Async;
16 | import org.springframework.scheduling.annotation.EnableAsync;
17 | import org.springframework.stereotype.Component;
18 |
19 | /**
20 | * @Descriptions: 专门发送通知的监听器
21 | */
22 | @EnableAsync
23 | @Component
24 | public class AlarmListener implements ApplicationListener {
25 |
26 | @Override
27 | @Async
28 | public void onApplicationEvent(AlarmEvent alarmEvent) {
29 | AlarmMessage alarmMessage = alarmEvent.getAlarmMessage();
30 | Alarm.AlarmType alarmType = alarmMessage.getAlarmType();//获取通知方式
31 | int[] scatter = alarmType.scatter();
32 | for(int code:scatter){
33 | SendNotice instantce = AlarmNoticeFacory.getInstantce(Alarm.getAlarmType(code));
34 | instantce.send(null);
35 | }
36 | }
37 |
38 | public static void main(String[] args) {
39 | int a=25;
40 | String s = Integer.toBinaryString(a);
41 | int length = s.replaceAll("0", "").length();
42 | char[] chars = s.toCharArray();
43 | int[] arrs= new int[length];
44 | for(int i=0,j=0;i
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.exception;
23 |
24 | import java.io.PrintStream;
25 | import java.io.PrintWriter;
26 |
27 | public class TimeoutException extends BasicException {
28 | public TimeoutException() {
29 | super();
30 | }
31 |
32 | public TimeoutException(String msg) {
33 | super(msg);
34 | }
35 |
36 | public TimeoutException(Throwable nestedThrowable) {
37 | super(nestedThrowable);
38 | }
39 |
40 | public TimeoutException(String msg, Throwable nestedThrowable) {
41 | super(msg, nestedThrowable);
42 | }
43 |
44 | @Override
45 | public void printStackTrace() {
46 | super.printStackTrace();
47 | }
48 |
49 | @Override
50 | public void printStackTrace(PrintStream ps) {
51 | super.printStackTrace(ps);
52 | }
53 |
54 | @Override
55 | public void printStackTrace(PrintWriter pw) {
56 | super.printStackTrace(pw);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/serialize/Serializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.common.serialize;
23 |
24 | import com.jobxhub.common.ext.SPI;
25 |
26 | import java.io.IOException;
27 | /**
28 | * Serialization. (SPI, Singleton, ThreadSafe)
29 | */
30 | @SPI
31 | public interface Serializer {
32 |
33 | /**
34 | * get content type id
35 | *
36 | * @return content type id
37 | */
38 | byte getContentTypeId();
39 |
40 | /**
41 | * get content type
42 | *
43 | * @return content type
44 | */
45 | String getContentType();
46 |
47 | /**
48 | * create serializer
49 | *
50 | * @return serializer
51 | * @throws IOException
52 | */
53 | byte[] serialize(Object object) throws IOException;
54 |
55 | /**
56 | * create deserializer
57 | *
58 | * @param bytes
59 | * @return deserializer
60 | * @throws IOException
61 | */
62 | T deserialize(byte[] bytes,Class clazz) throws IOException;
63 |
64 | }
--------------------------------------------------------------------------------
/jobx-common/src/main/java/com/jobxhub/common/graph/Graph.java:
--------------------------------------------------------------------------------
1 | package com.jobxhub.common.graph;
2 | /**
3 | * @Package org.opencron.common.graph
4 | * @Title: Graph
5 | * @author hitechr
6 | * @date 2018/4/11 13:03
7 | * @version V1.0
8 | */
9 |
10 | import java.util.HashMap;
11 | import java.util.HashSet;
12 | import java.util.Map;
13 | import java.util.Set;
14 |
15 | /**
16 | * @Descriptions:
17 | */
18 | public class Graph {
19 |
20 | /**
21 | * 图中节点的集合
22 | */
23 | public Set vertexSet= new HashSet<>();
24 |
25 | /**
26 | * 相邻的节点,纪录边
27 | */
28 | public Map> edgeNode = new HashMap<>();
29 |
30 | /**
31 | * 将节点添加到图中
32 | * @param source
33 | * @param target
34 | * @return
35 | */
36 | public Graph addNode(Node source,Node target){
37 | if(source==null
38 | || target==null){
39 | return this;
40 | }
41 |
42 | if(target.getLevel()<=source.getLevel()){
43 | target.setLevel(source.getLevel()+1);
44 | }
45 |
46 | if(!vertexSet.contains(source)){
47 | vertexSet.add(source);
48 | }
49 |
50 | if(!vertexSet.contains(target)){
51 | vertexSet.add(target);
52 | }
53 | if(edgeNode.containsKey(source)
54 | && edgeNode.get(source).contains(target)){
55 | return this;
56 | }
57 | if(edgeNode.containsKey(source)){
58 | edgeNode.get(source).add(target);
59 | }else {
60 | Set targetSet = new HashSet<>();
61 | targetSet.add(target);
62 | edgeNode.put(source,targetSet);
63 | }
64 | target.pathIn();
65 | return this;
66 | }
67 |
68 |
69 | public Set getVertexSet() {
70 | return vertexSet;
71 | }
72 |
73 | public Map> getEdgeNode() {
74 | return edgeNode;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/util/PageUtils.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.server.util;
23 |
24 | import com.jobxhub.common.util.DateUtils;
25 | import org.quartz.TriggerUtils;
26 | import org.quartz.impl.triggers.CronTriggerImpl;
27 |
28 | import java.text.ParseException;
29 | import java.util.ArrayList;
30 | import java.util.Date;
31 | import java.util.List;
32 |
33 | public class PageUtils {
34 |
35 | public static List getRecentTriggerTime(String cron) {
36 | List list = new ArrayList();
37 | try {
38 | CronTriggerImpl cronTriggerImpl = new CronTriggerImpl();
39 | cronTriggerImpl.setCronExpression(cron);
40 | List dates = TriggerUtils.computeFireTimes(cronTriggerImpl, null, 5);
41 | for (Date date : dates) {
42 | list.add(DateUtils.parseStringFromDate(date,DateUtils.format));
43 | }
44 | } catch (ParseException e) {
45 | e.printStackTrace();
46 | }
47 | return list;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/dao/JobDao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.dao;
22 |
23 | import com.jobxhub.server.domain.JobBean;
24 | import com.jobxhub.server.tag.PageBean;
25 | import org.apache.ibatis.annotations.Param;
26 |
27 | import java.util.List;
28 | import java.util.Map;
29 |
30 | public interface JobDao {
31 |
32 | List getAll();
33 |
34 | List getByPageBean(@Param("pager") PageBean pageBean);
35 |
36 | int getCount(@Param("filter") Map filter);
37 |
38 | JobBean getById(Long id);
39 |
40 | List getByAgent(Long agentId);
41 |
42 | int existsCount(@Param("jobId") Long jobId, @Param("agentId") Long agentId, @Param("name") String name);
43 |
44 | List getScheduleJob();
45 |
46 | void save(JobBean job);
47 |
48 | void update(JobBean job);
49 |
50 | void delete(Long id);
51 |
52 | void updateToken(@Param("jobId") Long jobId,@Param("token") String token);
53 |
54 | void pause(@Param("jobId") Long jobId,@Param("pause") Boolean pause);
55 | }
56 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/dao/GroupDao.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 | package com.jobxhub.server.dao;
22 |
23 | import com.jobxhub.server.domain.AgentGroupBean;
24 | import com.jobxhub.server.domain.GroupBean;
25 | import com.jobxhub.server.tag.PageBean;
26 | import org.apache.ibatis.annotations.Param;
27 |
28 | import java.util.List;
29 | import java.util.Map;
30 |
31 | public interface GroupDao {
32 |
33 | List getByPageBean(@Param("pager") PageBean pageBean);
34 |
35 | int getCount(@Param("filter") Map filter);
36 |
37 | int getAgentCount(@Param("groupId") Long groupId);
38 |
39 | List getAll();
40 |
41 | List getForAgent();
42 |
43 | void save(GroupBean groupBean);
44 |
45 | void update(GroupBean groupBean);
46 |
47 | int existsCount(@Param("filter") Map filter);
48 |
49 | GroupBean getById(@Param("groupId") Long groupId);
50 |
51 | void saveGroup(@Param("groupId") Long groupId,@Param("agentIds")String[] agentIds);
52 |
53 | void deleteGroup(@Param("groupId") Long groupId);
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/jobx-server/src/main/java/com/jobxhub/server/dto/Status.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2015 The JobX Project
3 | *
4 | * Licensed to the Apache Software Foundation (ASF) under one
5 | * or more contributor license agreements. See the NOTICE file
6 | * distributed with this work for additional information
7 | * regarding copyright ownership. The ASF licenses this file
8 | * to you under the Apache License, Version 2.0 (the
9 | * "License"); you may not use this file except in compliance
10 | * with the License. You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing,
15 | * software distributed under the License is distributed on an
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 | * KIND, either express or implied. See the License for the
18 | * specific language governing permissions and limitations
19 | * under the License.
20 | */
21 |
22 | package com.jobxhub.server.dto;
23 |
24 |
25 | import java.io.Serializable;
26 |
27 | public class Status implements Serializable {
28 |
29 | private boolean status;
30 |
31 | public Status(boolean status) {
32 | this.status = status;
33 | }
34 |
35 | public static Status FALSE = new Status(false);
36 |
37 | public static Status TRUE = new Status(true);
38 |
39 | public boolean isStatus() {
40 | return status;
41 | }
42 |
43 | public void setStatus(boolean status) {
44 | this.status = status;
45 | }
46 |
47 | public static Status getFALSE() {
48 | return FALSE;
49 | }
50 |
51 | public static void setFALSE(Status FALSE) {
52 | Status.FALSE = FALSE;
53 | }
54 |
55 | public static Status getTRUE() {
56 | return TRUE;
57 | }
58 |
59 | public static void setTRUE(Status TRUE) {
60 | Status.TRUE = TRUE;
61 | }
62 |
63 | public static Status create(boolean b) {
64 | return new Status(b);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------