-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #693 from hangzhang925/master
Refactor KAFKA processor to wherehows-kafka module
- Loading branch information
Showing
42 changed files
with
2,831 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright 2015 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
package wherehows.dao; | ||
|
||
import javax.persistence.EntityManager; | ||
import javax.persistence.EntityManagerFactory; | ||
|
||
|
||
public class BaseDao { | ||
|
||
final EntityManagerFactory entityManagerFactory; | ||
|
||
public BaseDao(EntityManagerFactory factory) { | ||
this.entityManagerFactory = factory; | ||
} | ||
|
||
public void update(Object record) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
entityManager.getTransaction().begin(); | ||
entityManager.merge(record); | ||
entityManager.getTransaction().commit(); | ||
entityManager.close(); | ||
} | ||
|
||
|
||
} |
47 changes: 47 additions & 0 deletions
47
wherehows-dao/src/main/java/wherehows/dao/ClusterInfoDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright 2015 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
package wherehows.dao; | ||
|
||
import java.util.List; | ||
import javax.persistence.EntityManager; | ||
import javax.persistence.EntityManagerFactory; | ||
import javax.persistence.criteria.CriteriaBuilder; | ||
import javax.persistence.criteria.CriteriaQuery; | ||
import javax.persistence.criteria.Root; | ||
import lombok.SneakyThrows; | ||
import wherehows.models.ClusterInfo; | ||
|
||
|
||
public class ClusterInfoDao extends BaseDao { | ||
|
||
public ClusterInfoDao(EntityManagerFactory factory) { | ||
super(factory); | ||
} | ||
|
||
@SneakyThrows | ||
public List<ClusterInfo> findAll() { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
CriteriaBuilder cb = entityManager.getCriteriaBuilder(); | ||
CriteriaQuery<ClusterInfo> criteria = cb.createQuery(ClusterInfo.class); | ||
Root<ClusterInfo> entityRoot = criteria.from(ClusterInfo.class); | ||
criteria.select(entityRoot); | ||
try { | ||
return entityManager.createQuery(criteria) | ||
.getResultList(); | ||
} finally { | ||
entityManager.close(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
wherehows-dao/src/main/java/wherehows/dao/DatasetSchemaInfoDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright 2015 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
package wherehows.dao; | ||
|
||
import javax.persistence.EntityManager; | ||
import javax.persistence.EntityManagerFactory; | ||
import javax.persistence.criteria.CriteriaBuilder; | ||
import javax.persistence.criteria.CriteriaQuery; | ||
import javax.persistence.criteria.Root; | ||
import lombok.SneakyThrows; | ||
import wherehows.models.DatasetSchemaInfo; | ||
|
||
|
||
public class DatasetSchemaInfoDao extends BaseDao { | ||
|
||
public DatasetSchemaInfoDao(EntityManagerFactory factory) { | ||
super(factory); | ||
} | ||
|
||
@SneakyThrows | ||
public DatasetSchemaInfo findById(int datasetId) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
CriteriaBuilder cb = entityManager.getCriteriaBuilder(); | ||
CriteriaQuery<DatasetSchemaInfo> criteria = cb.createQuery(DatasetSchemaInfo.class); | ||
Root<DatasetSchemaInfo> entityRoot = criteria.from(DatasetSchemaInfo.class); | ||
criteria.select(entityRoot).where(cb.equal(entityRoot.get("dataset_id"), datasetId)); | ||
|
||
try { | ||
return entityManager.createQuery(criteria).getSingleResult(); | ||
} finally { | ||
entityManager.close(); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
wherehows-dao/src/main/java/wherehows/dao/DictDatasetDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Copyright 2015 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
package wherehows.dao; | ||
|
||
import java.util.Objects; | ||
import javax.persistence.EntityManager; | ||
import javax.persistence.EntityManagerFactory; | ||
import javax.persistence.criteria.CriteriaBuilder; | ||
import javax.persistence.criteria.CriteriaQuery; | ||
import javax.persistence.criteria.Root; | ||
import lombok.SneakyThrows; | ||
import wherehows.models.DictDataset; | ||
|
||
|
||
public class DictDatasetDao extends BaseDao { | ||
|
||
public DictDatasetDao(EntityManagerFactory factory) { | ||
super(factory); | ||
} | ||
|
||
@SneakyThrows | ||
public DictDataset findByUrn(String urn) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
CriteriaBuilder cb = entityManager.getCriteriaBuilder(); | ||
CriteriaQuery<DictDataset> criteria = cb.createQuery(DictDataset.class); | ||
Root<DictDataset> entityRoot = criteria.from(DictDataset.class); | ||
criteria.select(entityRoot); | ||
criteria.where(cb.equal(entityRoot.get("urn"), urn)); | ||
try { | ||
return entityManager.createQuery(criteria).getSingleResult(); | ||
} finally { | ||
entityManager.close(); | ||
} | ||
} | ||
|
||
@SneakyThrows | ||
public DictDataset findById(int datasetId) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
CriteriaBuilder cb = entityManager.getCriteriaBuilder(); | ||
CriteriaQuery<DictDataset> criteria = cb.createQuery(DictDataset.class); | ||
Root<DictDataset> entityRoot = criteria.from(DictDataset.class); | ||
criteria.select(entityRoot); | ||
criteria.where(cb.equal(entityRoot.get("dataset_id"), datasetId)); | ||
try { | ||
return entityManager.createQuery(criteria).getSingleResult(); | ||
} finally { | ||
entityManager.close(); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
wherehows-dao/src/main/java/wherehows/dao/FieldDetailDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright 2015 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
package wherehows.dao; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import javax.persistence.EntityManager; | ||
import javax.persistence.EntityManagerFactory; | ||
import javax.persistence.criteria.CriteriaBuilder; | ||
import javax.persistence.criteria.CriteriaQuery; | ||
import javax.persistence.criteria.Root; | ||
import lombok.SneakyThrows; | ||
import wherehows.models.DictFieldDetail; | ||
|
||
|
||
public class FieldDetailDao extends BaseDao { | ||
|
||
private static final String DELETE_BY_DATASET_ID = "DELETE FROM dict_field_detail WHERE dataset_id = :datasetId"; | ||
|
||
public FieldDetailDao(EntityManagerFactory factory) { | ||
super(factory); | ||
} | ||
|
||
@SneakyThrows | ||
public List<DictFieldDetail> findById(int datasetId) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
CriteriaBuilder cb = entityManager.getCriteriaBuilder(); | ||
CriteriaQuery<DictFieldDetail> criteria = cb.createQuery(DictFieldDetail.class); | ||
Root<DictFieldDetail> entityRoot = criteria.from(DictFieldDetail.class); | ||
criteria.select(entityRoot); | ||
criteria.where(cb.equal(entityRoot.get("dataset_Id"), datasetId)); | ||
try { | ||
return entityManager.createQuery(criteria).getResultList(); | ||
} finally { | ||
entityManager.close(); | ||
} | ||
} | ||
|
||
@SneakyThrows | ||
public void deleteByDatasetId(int datasetId) { | ||
EntityManager entityManager = entityManagerFactory.createEntityManager(); | ||
try { | ||
entityManager.createQuery(DELETE_BY_DATASET_ID).executeUpdate(); | ||
} finally { | ||
entityManager.close(); | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
wherehows-dao/src/main/java/wherehows/models/ClusterInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Copyright 2015 LinkedIn Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
*/ | ||
package wherehows.models; | ||
|
||
import java.util.Date; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
||
@Data | ||
@Entity | ||
@Table(name = "cfg_cluster") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ClusterInfo { | ||
|
||
@Id | ||
@Column(name = "cluster_id") | ||
int clusterId; | ||
|
||
@Column(name = "cluster_code") | ||
String clusterCode; | ||
|
||
@Column(name = "cluster_short_name") | ||
String clusterShortName; | ||
|
||
@Column(name = "cluster_type") | ||
String clusterType; | ||
|
||
@Column(name = "deployment_tier_code") | ||
String deploymentTierCode; | ||
|
||
@Column(name = "data_center_code") | ||
String datacenterCode; | ||
|
||
@Column(name = "last_modified") | ||
Date lastModified; | ||
|
||
@Column(name = "description") | ||
String description; | ||
} |
Oops, something went wrong.