Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
4b555de
changes
Mar 25, 2021
c813679
removing useless stuff
Mar 25, 2021
866dc7f
tidy up
Mar 25, 2021
2a3a633
remove unused imports
Mar 25, 2021
56d8697
adding classes
Mar 31, 2021
21c2dce
clean up
Mar 31, 2021
17c38c0
idk
Mar 31, 2021
afb6bbc
metastore
Mar 31, 2021
5e28ddd
space
Mar 31, 2021
486bc1a
fixing service classes
Mar 31, 2021
32aa4a8
sabe tables
Mar 31, 2021
e5f2bcc
test class
Mar 31, 2021
34cc340
works
Mar 31, 2021
62cfc65
remove mthod
Apr 1, 2021
0099efc
value
Apr 1, 2021
8b5dc9a
adding classes
Apr 6, 2021
41d94d1
delete file
Apr 6, 2021
b1299a1
classes
Apr 6, 2021
cd461c5
override
Apr 6, 2021
d73afe5
pages
Apr 6, 2021
77ddf10
wrong import
Apr 6, 2021
50881e3
fixing test class
Apr 6, 2021
e19796f
table name
Apr 6, 2021
0b04c31
adding controller test class
Apr 6, 2021
b3a8ae6
controller test class does not work
Apr 7, 2021
36e4cac
pom
Apr 7, 2021
20d82d4
changes
Apr 7, 2021
13b5e52
renaming modules
Apr 7, 2021
20fc86b
renaming variables
Apr 7, 2021
f7693e9
generating dummy data class
Apr 8, 2021
021d949
fixing test class
Apr 8, 2021
eed7b84
renaming method
Apr 8, 2021
c378940
adding verification mocks
Apr 8, 2021
3dea0bf
impl class
Apr 8, 2021
72fca3f
add filtering in controller
Apr 9, 2021
a325002
adding specs
Apr 9, 2021
8a865ec
idk
Apr 9, 2021
4796fea
doesn't work
Apr 12, 2021
e6cbe4e
idk whats going on
Apr 12, 2021
9294f26
Fix
Apr 12, 2021
810ba01
Merge branch 'egdl-2015' of https://github.com/shermosa/beekeeper int…
Apr 12, 2021
baed7ed
stuff
Apr 12, 2021
11931c8
stuff
Apr 12, 2021
bc0dbd1
works without the mockmvc and verifications
Apr 12, 2021
61e123e
reproducing error
Apr 12, 2021
dc173f3
reproducing error
Apr 12, 2021
598edba
still doesn't work, utf8 error
Apr 13, 2021
896e506
compiles correctly without test
Apr 13, 2021
3cc729f
compiles fine
Apr 13, 2021
8de5070
compiles fine
Apr 13, 2021
b17cb11
ACTUALLY compiles correctyl
Apr 13, 2021
c424e7c
reproducing error
Apr 15, 2021
500df9b
some of it works
Apr 15, 2021
226642a
improvement
Apr 16, 2021
dc7a449
mysqlutils
Apr 16, 2021
b9f0e69
i think i fixed it
Apr 16, 2021
6afbab8
taking out dependencies and systemoutprintln
Apr 16, 2021
ecd6378
compiles correctly/checked
Apr 16, 2021
ba321db
taking out jetty redundant exlcusions
Apr 19, 2021
420f91b
renaming variables
Apr 19, 2021
c36d6ad
taking out useless exclusions
Apr 19, 2021
83b906c
tidy up
Apr 19, 2021
877dea2
tidy up
Apr 19, 2021
3239029
relocating TestApplication class
Apr 20, 2021
6f83af6
renaming class names
Apr 20, 2021
637b22d
adding test for filtering
Apr 21, 2021
9d6c5e6
test for wrong url
Apr 21, 2021
baf6ea8
test for paging
Apr 21, 2021
c972dc7
adding api integration test class
Apr 22, 2021
e3a903a
ading beforeeach and aftereach methods
Apr 22, 2021
e7eb6fb
trying to run integration tests
Apr 23, 2021
3711af0
renaming
Apr 26, 2021
b1f0958
reproducing error
Apr 28, 2021
f9b0bd9
works
May 4, 2021
b806e8d
doesnt work
May 4, 2021
cdc8d65
works,two test written
May 4, 2021
d565a5e
works forreal
May 4, 2021
0975cb9
cleaning up
May 4, 2021
ccc4376
adding tests, works
May 4, 2021
f87c3c0
database filtering test done
May 4, 2021
cb9fd43
adding test for housekeeping filter works
May 4, 2021
350fadc
add test for lifecycleeventtyoe
May 5, 2021
1a3cfd2
adding lombok
May 7, 2021
ac1e806
dummy data
May 7, 2021
0b49bbf
reproducing error
May 10, 2021
3be3297
reproducing error
May 10, 2021
79a1df0
fixed prob
May 10, 2021
474c60f
IJ doesn't recognise class
May 11, 2021
d68c84a
error
May 11, 2021
001d6a3
compiles correctly after finished lombok
May 11, 2021
a5e4681
this fixes intellij error but should be removed later
May 11, 2021
b4864a7
weird error
May 12, 2021
18a5409
works
May 12, 2021
b5031d3
tests work
May 12, 2021
1dc01f8
correcting tests
May 12, 2021
e520e19
timestamp cleanup work
May 12, 2021
3b5468c
tofy up
May 12, 2021
75c040d
deleted after test
May 13, 2021
570bc41
1 more test
May 13, 2021
a4c453a
added 1 more test
May 13, 2021
0f4b1fa
tidy up
May 13, 2021
2e2e8e2
500 error
May 14, 2021
14ca76c
Revert "500 error"
May 14, 2021
98dd452
creating response classes
May 14, 2021
f7efe76
adding classes
May 14, 2021
dae91e6
path service has an error
May 14, 2021
b46252a
making a return object
May 18, 2021
e32c151
return object
May 19, 2021
08a3155
fixing folder name
May 19, 2021
4b1e9eb
tests fail
May 20, 2021
a55f363
adding new servic
May 20, 2021
0532a42
adding
May 20, 2021
43cfbd6
currently adds lifecycles together correclty but doesnt delete duplik…
May 20, 2021
5abfc4e
almost works, need to make sure theyre different lifecycles
May 20, 2021
caeb296
packing tables together works
May 21, 2021
15b7162
tidy up
May 21, 2021
9bbad7e
i dont know whats here
May 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions beekeeper-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

<artifactId>beekeeper-api</artifactId>

<properties>
<specification-arg-resolver.version>2.6.1</specification-arg-resolver.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -20,6 +24,36 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.expediagroup</groupId>
<artifactId>beekeeper-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.kaczmarzyk</groupId>
<artifactId>specification-arg-resolver</artifactId>
<version>${specification-arg-resolver.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20080701</version>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what resolved your JSON dependency issue?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yas queen

</dependency>

<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (C) 2019-2021 Expedia, Inc.
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.expediagroup.beekeeper.api;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

@SpringBootApplication
@EnableConfigurationProperties
@EntityScan(basePackages = { "com.expediagroup.beekeeper.core.model" })
@EnableJpaRepositories(basePackages = { "com.expediagroup.beekeeper.core.repository" })
@ComponentScan(basePackages = {
"com.expediagroup.beekeeper.api.conf",
"com.expediagroup.beekeeper.api.controller",
"com.expediagroup.beekeeper.api.service" })
public class BeekeeperApiApplication {

@Autowired
private ObjectMapper objectMapper;

public static void main(String[] args) {
SpringApplication.run(BeekeeperApiApplication.class, args);
}

@PostConstruct
public void setUp() {
objectMapper.registerModule(new JavaTimeModule());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright (C) 2019-2021 Expedia, Inc.
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.expediagroup.beekeeper.api.conf;

import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver;

@Configuration
@EnableJpaRepositories
public class JPAConfiguration implements WebMvcConfigurer {

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new SpecificationArgumentResolver());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (C) 2019-2021 Expedia, Inc.
*
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.expediagroup.beekeeper.api.controller;


import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

import static com.expediagroup.beekeeper.api.response.HousekeepingMetadataResponse.convertToHouseKeepingMetadataResponsePage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import net.kaczmarzyk.spring.data.jpa.domain.EqualIgnoreCase;
import net.kaczmarzyk.spring.data.jpa.domain.GreaterThan;
import net.kaczmarzyk.spring.data.jpa.domain.LessThan;
import net.kaczmarzyk.spring.data.jpa.web.annotation.And;
import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec;

import com.expediagroup.beekeeper.api.response.HousekeepingMetadataResponse;
import com.expediagroup.beekeeper.api.service.BeekeeperService;
import com.expediagroup.beekeeper.api.service.HousekeepingMetadataService;
import com.expediagroup.beekeeper.core.model.HousekeepingMetadata;

@RequestMapping("/api/v1")
@RestController
public class BeekeeperController {
private final BeekeeperService beekeeperService;

@Autowired
public BeekeeperController(HousekeepingMetadataService housekeepingMetadataService,
BeekeeperService beekeeperService) {
this.beekeeperService = beekeeperService;
}

@GetMapping(path = "/tables", produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Page<HousekeepingMetadataResponse>> getAll(
@And({
@Spec(path = "tableName", params = "table_name", spec = EqualIgnoreCase.class),
@Spec(path = "databaseName", params = "database_name", spec = EqualIgnoreCase.class),
@Spec(path = "housekeepingStatus", params = "housekeeping_status", spec = EqualIgnoreCase.class),
@Spec(path = "lifecycleType", params = "lifecycle_type", spec = EqualIgnoreCase.class),
@Spec(path = "cleanupTimestamp", params = "deleted_before", spec = LessThan.class),
@Spec(path = "cleanupTimestamp", params = "deleted_after", spec = GreaterThan.class),
@Spec(path = "creationTimestamp", params = "registered_before", spec = LessThan.class),
@Spec(path = "creationTimestamp", params = "registered_after", spec = GreaterThan.class)
})
Specification<HousekeepingMetadata> spec, Pageable pageable) {
return ResponseEntity.ok(beekeeperService.getAllTables(spec, pageable));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.expediagroup.beekeeper.api.response;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Table;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;

import lombok.Builder;
import lombok.Value;

import com.expediagroup.beekeeper.core.model.HousekeepingMetadata;

@Value
@Builder
@Table(name = "housekeeping_metadata")
public class HousekeepingMetadataResponse {

@Column(name = "database_name", nullable = false)
String databaseName;

@Column(name = "table_name", nullable = false)
String tableName;

@Column(name = "path", nullable = false)
String path;

@Column(name = "lifecycles", nullable = false)
List<Lifecycle> lifecycles;

public static HousekeepingMetadataResponse convertToHouseKeepingMetadataResponse(
HousekeepingMetadata housekeepingMetadata) {
List<Lifecycle> lifecyclesList = new ArrayList<>();
Lifecycle lifecycle = Lifecycle.builder()
.lifecycleEventType(housekeepingMetadata.getLifecycleType())
.configuration(Map.of(
"beekeeper.unreferenced.data.retention.period",housekeepingMetadata.getCleanupDelay().toString(),
"clean up timestamp", housekeepingMetadata.getCleanupTimestamp().toString()
))
.build()
;
lifecyclesList.add(lifecycle);

return HousekeepingMetadataResponse.builder()
.databaseName(housekeepingMetadata.getDatabaseName())
.tableName(housekeepingMetadata.getTableName())
.path(housekeepingMetadata.getPath())
.lifecycles(lifecyclesList)
.build();
}

public static Page<HousekeepingMetadataResponse> convertToHouseKeepingMetadataResponsePage(List<HousekeepingMetadata> housekeepingMetadataList){
List<HousekeepingMetadataResponse> housekeepingMetadataResponseList = new ArrayList<>();
for (HousekeepingMetadata housekeepingMetadata : housekeepingMetadataList) {
HousekeepingMetadataResponse housekeepingMetadataResponse = convertToHouseKeepingMetadataResponse(housekeepingMetadata);
int repeatedTablePosition = checkIfTableExists(housekeepingMetadataResponseList, housekeepingMetadata);

if(repeatedTablePosition!=-1){
housekeepingMetadataResponse = housekeepingMetadataResponseList.get(repeatedTablePosition);
housekeepingMetadataResponseList.remove(repeatedTablePosition);
Lifecycle lifecycle = Lifecycle.builder()
.lifecycleEventType(housekeepingMetadata.getLifecycleType())
.configuration(Map.of(
"beekeeper.unreferenced.data.retention.period",housekeepingMetadata.getCleanupDelay().toString(),
"clean up timestamp", housekeepingMetadata.getCleanupTimestamp().toString()
))
.build();
housekeepingMetadataResponse.addLifecycle(lifecycle);
}

housekeepingMetadataResponseList.add(housekeepingMetadataResponse);
}
return new PageImpl<>(housekeepingMetadataResponseList);
}

public static int checkIfTableExists(
List<HousekeepingMetadataResponse> housekeepingMetadataResponseList, HousekeepingMetadata housekeepingMetadata){
int count = -1;
int positionOfRepeatedTable = -1;
String tableName1 = housekeepingMetadata.getTableName();
String databaseName1 = housekeepingMetadata.getDatabaseName();
if(!housekeepingMetadataResponseList.isEmpty()) {
for (HousekeepingMetadataResponse table : housekeepingMetadataResponseList) {
count++;
String tableName2 = table.getTableName();
String databaseName2 = table.getDatabaseName();
if (tableName1.equals(tableName2) && databaseName1.equals(databaseName2)) {
positionOfRepeatedTable = count;
}
}
}
return positionOfRepeatedTable;
}

public void addLifecycle(Lifecycle lifecycle){
lifecycles.add(lifecycle);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.expediagroup.beekeeper.api.response;

import java.util.Map;

import lombok.Builder;
import lombok.Value;

@Value
@Builder
public class Lifecycle {

String lifecycleEventType;
Map<String, String> configuration;



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.expediagroup.beekeeper.api.service;

import static com.expediagroup.beekeeper.api.response.HousekeepingMetadataResponse.convertToHouseKeepingMetadataResponsePage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import com.expediagroup.beekeeper.api.response.HousekeepingMetadataResponse;
import com.expediagroup.beekeeper.core.model.HousekeepingMetadata;

@Service
public class BeekeeperService {

private final HousekeepingMetadataService housekeepingMetadataService;

@Autowired
public BeekeeperService(
HousekeepingMetadataService housekeepingMetadataService) {this.housekeepingMetadataService = housekeepingMetadataService;}

public Page<HousekeepingMetadataResponse> getAllTables(Specification<HousekeepingMetadata> spec, Pageable pageable) {
return convertToHouseKeepingMetadataResponsePage(housekeepingMetadataService.getAll(spec, pageable).getContent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.expediagroup.beekeeper.api;
package com.expediagroup.beekeeper.api.service;

import org.springframework.web.bind.annotation.RestController;

@RestController
public class BeekeeperController {

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;

import com.expediagroup.beekeeper.core.model.HousekeepingEntity;
import com.expediagroup.beekeeper.core.model.HousekeepingMetadata;
import com.expediagroup.beekeeper.core.model.HousekeepingPath;

public interface HousekeepingEntityService<U extends HousekeepingEntity> {

Page<U> getAll(Specification<U> spec, Pageable pageable);

}
Loading