Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apollo
Commits
f753bb93
Commit
f753bb93
authored
Nov 17, 2018
by
nobodyiam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes
https://github.com/ctripcorp/apollo/issues/1677
parent
c121a9e6
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
104 additions
and
51 deletions
+104
-51
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java
...ework/apollo/biz/repository/ReleaseHistoryRepository.java
+3
-0
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryService.java
...p/framework/apollo/biz/service/ReleaseHistoryService.java
+5
-0
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
...om/ctrip/framework/apollo/biz/service/ReleaseService.java
+86
-36
apollo-biz/src/test/resources/sql/release-creation-test.sql
apollo-biz/src/test/resources/sql/release-creation-test.sql
+1
-1
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
.../java/com/ctrip/framework/apollo/BaseIntegrationTest.java
+8
-6
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultMetaServerProviderTest.java
...ework/apollo/internals/DefaultMetaServerProviderTest.java
+0
-8
apollo-common/src/main/java/com/ctrip/framework/apollo/common/constants/ReleaseOperationContext.java
...work/apollo/common/constants/ReleaseOperationContext.java
+1
-0
No files found.
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/repository/ReleaseHistoryRepository.java
View file @
f753bb93
...
@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.biz.repository;
...
@@ -2,6 +2,7 @@ package com.ctrip.framework.apollo.biz.repository;
import
com.ctrip.framework.apollo.biz.entity.ReleaseHistory
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseHistory
;
import
java.util.Set
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Modifying
;
...
@@ -19,6 +20,8 @@ public interface ReleaseHistoryRepository extends PagingAndSortingRepository<Rel
...
@@ -19,6 +20,8 @@ public interface ReleaseHistoryRepository extends PagingAndSortingRepository<Rel
Page
<
ReleaseHistory
>
findByPreviousReleaseIdAndOperationOrderByIdDesc
(
long
previousReleaseId
,
int
operation
,
Pageable
pageable
);
Page
<
ReleaseHistory
>
findByPreviousReleaseIdAndOperationOrderByIdDesc
(
long
previousReleaseId
,
int
operation
,
Pageable
pageable
);
Page
<
ReleaseHistory
>
findByReleaseIdAndOperationInOrderByIdDesc
(
long
releaseId
,
Set
<
Integer
>
operations
,
Pageable
pageable
);
@Modifying
@Modifying
@Query
(
"update ReleaseHistory set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3"
)
@Query
(
"update ReleaseHistory set isdeleted=1,DataChange_LastModifiedBy = ?4 where appId=?1 and clusterName=?2 and namespaceName = ?3"
)
int
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
);
int
batchDelete
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
operator
);
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseHistoryService.java
View file @
f753bb93
...
@@ -6,6 +6,7 @@ import com.ctrip.framework.apollo.biz.entity.Audit;
...
@@ -6,6 +6,7 @@ import com.ctrip.framework.apollo.biz.entity.Audit;
import
com.ctrip.framework.apollo.biz.entity.ReleaseHistory
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseHistory
;
import
com.ctrip.framework.apollo.biz.repository.ReleaseHistoryRepository
;
import
com.ctrip.framework.apollo.biz.repository.ReleaseHistoryRepository
;
import
java.util.Set
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
...
@@ -43,6 +44,10 @@ public class ReleaseHistoryService {
...
@@ -43,6 +44,10 @@ public class ReleaseHistoryService {
return
releaseHistoryRepository
.
findByPreviousReleaseIdAndOperationOrderByIdDesc
(
previousReleaseId
,
operation
,
page
);
return
releaseHistoryRepository
.
findByPreviousReleaseIdAndOperationOrderByIdDesc
(
previousReleaseId
,
operation
,
page
);
}
}
public
Page
<
ReleaseHistory
>
findByReleaseIdAndOperationInOrderByIdDesc
(
long
releaseId
,
Set
<
Integer
>
operations
,
Pageable
page
)
{
return
releaseHistoryRepository
.
findByReleaseIdAndOperationInOrderByIdDesc
(
releaseId
,
operations
,
page
);
}
@Transactional
@Transactional
public
ReleaseHistory
createReleaseHistory
(
String
appId
,
String
clusterName
,
String
public
ReleaseHistory
createReleaseHistory
(
String
appId
,
String
clusterName
,
String
namespaceName
,
String
branchName
,
long
releaseId
,
long
previousReleaseId
,
int
operation
,
namespaceName
,
String
branchName
,
long
releaseId
,
long
previousReleaseId
,
int
operation
,
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java
View file @
f753bb93
This diff is collapsed.
Click to expand it.
apollo-biz/src/test/resources/sql/release-creation-test.sql
View file @
f753bb93
...
@@ -96,4 +96,4 @@ INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted
...
@@ -96,4 +96,4 @@ INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted
INSERT
INTO
`release`
(
`Id`
,
`ReleaseKey`
,
`Name`
,
`Comment`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`Configurations`
,
`IsAbandoned`
)
VALUES
(
6
,
'20160823102253-fc0071ddf9fd3260'
,
'20160823101703-release'
,
''
,
'test'
,
'default6'
,
'application'
,
'{"k1":"v1-1","k2":"v2-1","k3":"v3"}'
,
0
);
INSERT
INTO
`release`
(
`Id`
,
`ReleaseKey`
,
`Name`
,
`Comment`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`Configurations`
,
`IsAbandoned`
)
VALUES
(
6
,
'20160823102253-fc0071ddf9fd3260'
,
'20160823101703-release'
,
''
,
'test'
,
'default6'
,
'application'
,
'{"k1":"v1-1","k2":"v2-1","k3":"v3"}'
,
0
);
INSERT
INTO
`release`
(
`Id`
,
`ReleaseKey`
,
`Name`
,
`Comment`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`Configurations`
,
`IsAbandoned`
)
VALUES
(
7
,
'20160823102253-fc0071ddf9fd3260'
,
'20160823101703-release'
,
''
,
'test'
,
'default6'
,
'application'
,
'{"k1":"v1","k2":"v2"}'
,
0
);
INSERT
INTO
`release`
(
`Id`
,
`ReleaseKey`
,
`Name`
,
`Comment`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`Configurations`
,
`IsAbandoned`
)
VALUES
(
7
,
'20160823102253-fc0071ddf9fd3260'
,
'20160823101703-release'
,
''
,
'test'
,
'default6'
,
'application'
,
'{"k1":"v1","k2":"v2"}'
,
0
);
INSERT
INTO
`release`
(
`Id`
,
`ReleaseKey`
,
`Name`
,
`Comment`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`Configurations`
,
`IsAbandoned`
)
VALUES
(
8
,
'20160823102253-fc0071ddf9fd3260'
,
'20160823101703-release'
,
''
,
'test'
,
'child-cluster6'
,
'application'
,
'{"k1":"v1-2","k2":"v2
-1
","k3":"v3"}'
,
0
);
INSERT
INTO
`release`
(
`Id`
,
`ReleaseKey`
,
`Name`
,
`Comment`
,
`AppId`
,
`ClusterName`
,
`NamespaceName`
,
`Configurations`
,
`IsAbandoned`
)
VALUES
(
8
,
'20160823102253-fc0071ddf9fd3260'
,
'20160823101703-release'
,
''
,
'test'
,
'child-cluster6'
,
'application'
,
'{"k1":"v1-2","k2":"v2","k3":"v3"}'
,
0
);
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
View file @
f753bb93
package
com
.
ctrip
.
framework
.
apollo
;
package
com
.
ctrip
.
framework
.
apollo
;
import
java.io.File
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.ServerSocket
;
import
java.net.ServerSocket
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -16,6 +16,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
...
@@ -16,6 +16,7 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
import
org.eclipse.jetty.server.handler.ContextHandler
;
import
org.eclipse.jetty.server.handler.ContextHandler
;
import
org.eclipse.jetty.server.handler.ContextHandlerCollection
;
import
org.eclipse.jetty.server.handler.ContextHandlerCollection
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.AfterClass
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
...
@@ -25,9 +26,7 @@ import com.ctrip.framework.apollo.core.enums.Env;
...
@@ -25,9 +26,7 @@ import com.ctrip.framework.apollo.core.enums.Env;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.core.utils.ClassLoaderUtil
;
import
com.ctrip.framework.apollo.internals.DefaultInjector
;
import
com.ctrip.framework.apollo.internals.DefaultInjector
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.google.common.base.Charsets
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.google.common.io.Files
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
/**
/**
...
@@ -49,9 +48,12 @@ public abstract class BaseIntegrationTest{
...
@@ -49,9 +48,12 @@ public abstract class BaseIntegrationTest{
@BeforeClass
@BeforeClass
public
static
void
beforeClass
()
throws
Exception
{
public
static
void
beforeClass
()
throws
Exception
{
File
apolloEnvPropertiesFile
=
new
File
(
ClassLoaderUtil
.
getClassPath
(),
"apollo-env.properties"
);
System
.
setProperty
(
ConfigConsts
.
APOLLO_META_KEY
,
metaServiceUrl
);
Files
.
write
(
"dev.meta="
+
metaServiceUrl
,
apolloEnvPropertiesFile
,
Charsets
.
UTF_8
);
}
apolloEnvPropertiesFile
.
deleteOnExit
();
@AfterClass
public
static
void
afterClass
()
throws
Exception
{
System
.
clearProperty
(
ConfigConsts
.
APOLLO_META_KEY
);
}
}
@Before
@Before
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/DefaultMetaServerProviderTest.java
View file @
f753bb93
...
@@ -27,12 +27,4 @@ public class DefaultMetaServerProviderTest {
...
@@ -27,12 +27,4 @@ public class DefaultMetaServerProviderTest {
assertEquals
(
someMetaAddress
,
defaultMetaServerProvider
.
getMetaServerAddress
(
someEnv
));
assertEquals
(
someMetaAddress
,
defaultMetaServerProvider
.
getMetaServerAddress
(
someEnv
));
}
}
@Test
public
void
testWithNoSystemProperty
()
throws
Exception
{
Env
someEnv
=
Env
.
DEV
;
DefaultMetaServerProvider
defaultMetaServerProvider
=
new
DefaultMetaServerProvider
();
assertNull
(
defaultMetaServerProvider
.
getMetaServerAddress
(
someEnv
));
}
}
}
apollo-common/src/main/java/com/ctrip/framework/apollo/common/constants/ReleaseOperationContext.java
View file @
f753bb93
...
@@ -9,4 +9,5 @@ public interface ReleaseOperationContext {
...
@@ -9,4 +9,5 @@ public interface ReleaseOperationContext {
String
OLD_RULES
=
"oldRules"
;
String
OLD_RULES
=
"oldRules"
;
String
BASE_RELEASE_ID
=
"baseReleaseId"
;
String
BASE_RELEASE_ID
=
"baseReleaseId"
;
String
IS_EMERGENCY_PUBLISH
=
"isEmergencyPublish"
;
String
IS_EMERGENCY_PUBLISH
=
"isEmergencyPublish"
;
String
BRANCH_RELEASE_KEYS
=
"branchReleaseKeys"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment