commit_id
stringlengths
40
40
project
stringclasses
90 values
commit_message
stringlengths
5
2.21k
type
stringclasses
3 values
url
stringclasses
89 values
git_diff
stringlengths
283
4.32M
adbc3b32e7e7546c573e5144c4379f1a3924ca9f
arrayexpress$annotare2
A bit of refactoring of sign-up/sign-in functionality
p
https://github.com/arrayexpress/annotare2
diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/AppServletModule.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/AppServletModule.java index b0ffe1783..de380fd53 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/AppServletModule.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/AppServletModule.java @@ -149,8 +149,7 @@ protected void configureServlets() { bind(SubsTracking.class).in(SINGLETON); bind(SubsTrackingWatchdog.class).asEagerSingleton(); - bind(AuthService.class).to(AuthServiceImpl.class).in(SINGLETON); - bind(SignUpService.class).to(SignUpServiceImpl.class).in(SINGLETON); + bind(AccountService.class).to(AccountServiceImpl.class).in(SINGLETON); bind(AllRpcServicePaths.class).toInstance(allRpc); bind(AnnotareProperties.class).asEagerSingleton(); diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/ExportServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/ExportServlet.java index 15101cb3b..f8db8a0e2 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/ExportServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/ExportServlet.java @@ -25,7 +25,7 @@ import uk.ac.ebi.fg.annotare2.db.om.ExperimentSubmission; import uk.ac.ebi.fg.annotare2.db.om.User; import uk.ac.ebi.fg.annotare2.db.om.enums.Permission; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.rpc.MageTabFormat; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; @@ -52,7 +52,7 @@ public class ExportServlet extends HttpServlet { private static final Logger log = LoggerFactory.getLogger(ExportServlet.class); @Inject - private AuthService authService; + private AccountService accountService; @Inject private SubmissionManager submissionManager; @@ -91,7 +91,7 @@ private void exportMageTab(ExperimentSubmission submission, ZipOutputStream zip) private ExperimentSubmission getSubmission(HttpServletRequest request) throws ServletException { try { - User currentUser = authService.getCurrentUser(request.getSession()); + User currentUser = accountService.getCurrentUser(request.getSession()); return submissionManager.getExperimentSubmission(currentUser, getSubmissionId(request), Permission.VIEW); } catch (RecordNotFoundException e) { throw servletException(e); diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthService.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountService.java similarity index 83% rename from app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthService.java rename to app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountService.java index 96d5c1e98..82b954fd6 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthService.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountService.java @@ -26,11 +26,13 @@ /** * @author Olga Melnichuk */ -public interface AuthService { +public interface AccountService { + + ValidationErrors signUp(HttpServletRequest request) throws AccountServiceException; boolean isLoggedIn(HttpServletRequest request); - ValidationErrors login(HttpServletRequest request) throws LoginException; + ValidationErrors login(HttpServletRequest request) throws AccountServiceException; void logout(HttpSession session); diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginException.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceException.java similarity index 87% rename from app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginException.java rename to app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceException.java index 5bc2e21fd..8eb0db5e6 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginException.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceException.java @@ -19,9 +19,9 @@ /** * @author Olga Melnichuk */ -public class LoginException extends Exception { +public class AccountServiceException extends Exception { - public LoginException(String expAcc) { + public AccountServiceException(String expAcc) { super(expAcc); } } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceImpl.java similarity index 52% rename from app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthServiceImpl.java rename to app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceImpl.java index 1bdd3e46a..1faf49318 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/AccountServiceImpl.java @@ -16,6 +16,7 @@ package uk.ac.ebi.fg.annotare2.web.server.login; +import com.google.common.collect.ImmutableMap; import com.google.inject.Inject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,8 +26,10 @@ import uk.ac.ebi.fg.annotare2.web.server.login.utils.RequestParam; import uk.ac.ebi.fg.annotare2.web.server.login.utils.SessionAttribute; import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; +import uk.ac.ebi.fg.annotare2.web.server.services.EmailSender; import uk.ac.ebi.fg.annotare2.web.server.transaction.Transactional; +import javax.mail.MessagingException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -35,17 +38,19 @@ /** * @author Olga Melnichuk */ -public class AuthServiceImpl implements AuthService { +public class AccountServiceImpl implements AccountService { - private static final Logger log = LoggerFactory.getLogger(AuthServiceImpl.class); + private static final Logger log = LoggerFactory.getLogger(AccountServiceImpl.class); private static final SessionAttribute USER_EMAIL_ATTRIBUTE = new SessionAttribute("email"); private AccountManager accountManager; + private EmailSender emailer; @Inject - public AuthServiceImpl(AccountManager accountManager) { + public AccountServiceImpl(AccountManager accountManager, EmailSender emailer) { this.accountManager = accountManager; + this.emailer = emailer; } public boolean isLoggedIn(HttpServletRequest request) { @@ -53,13 +58,40 @@ public boolean isLoggedIn(HttpServletRequest request) { } @Transactional - public ValidationErrors login(HttpServletRequest request) throws LoginException { + public ValidationErrors signUp(HttpServletRequest request) throws AccountServiceException { + SignUpParams params = new SignUpParams(request); + ValidationErrors errors = params.validate(); + if (errors.isEmpty()) { + if (null != accountManager.getByEmail(params.getEmail())) { + errors.append("email", "User with this email already exists"); + } else { + User u = accountManager.createUser(params.getName(), params.getEmail(), params.getPassword()); + try { + emailer.sendFromTemplate( + EmailSender.NEW_USER_TEMPLATE, + ImmutableMap.of( + "to.name", u.getName(), + "to.email", u.getEmail(), + "verification.token", u.getVerificationToken() + ) + ); + } catch (MessagingException x) { + // + } + } + } + return errors; + } + + + @Transactional + public ValidationErrors login(HttpServletRequest request) throws AccountServiceException { LoginParams params = new LoginParams(request); ValidationErrors errors = params.validate(); if (errors.isEmpty()) { if (!accountManager.isValid(params.getEmail(), params.getPassword())) { log.debug("User '{}' entered invalid params", params.getEmail()); - throw new LoginException("Sorry, the email or password you entered is not valid."); + throw new AccountServiceException("Sorry, the email or password you entered is not valid."); } log.debug("User '{}' logged in", params.getEmail()); USER_EMAIL_ATTRIBUTE.set(request.getSession(), params.getEmail()); @@ -110,4 +142,48 @@ public String getPassword() { return password.getValue(); } } + + static class SignUpParams { + public static final String NAME_PARAM = "name"; + public static final String EMAIL_PARAM = "email"; + public static final String PASSWORD_PARAM = "password"; + public static final String CONFIRM_PASSWORD_PARAM = "confirm-password"; + + private final RequestParam name; + private final RequestParam email; + private final RequestParam password; + private final RequestParam confirmPassword; + + private SignUpParams(HttpServletRequest request) { + name = RequestParam.from(request, NAME_PARAM); + email = RequestParam.from(request, EMAIL_PARAM); + password = RequestParam.from(request, PASSWORD_PARAM); + confirmPassword = RequestParam.from(request, CONFIRM_PASSWORD_PARAM); + } + + public ValidationErrors validate() { + ValidationErrors errors = new ValidationErrors(); + for (RequestParam p : asList(name, email, password)) { + if (p.isEmpty()) { + errors.append(p.getName(), "Please specify a value, " + p.getName() + " is required"); + } + } + if (!password.getValue().equals(confirmPassword.getValue())) { + errors.append(confirmPassword.getName(), "Passwords do not match"); + } + return errors; + } + + public String getName() { + return name.getValue(); + } + + public String getEmail() { + return email.getValue(); + } + + public String getPassword() { + return password.getValue(); + } + } } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ChangePasswordServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ChangePasswordServlet.java index 0fb95fac0..084ec5aa6 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ChangePasswordServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ChangePasswordServlet.java @@ -17,7 +17,50 @@ * */ +import com.google.inject.Inject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; + +import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +import static uk.ac.ebi.fg.annotare2.web.server.login.ServletNavigation.LOGIN; +import static uk.ac.ebi.fg.annotare2.web.server.login.ServletNavigation.SIGNUP; public class ChangePasswordServlet extends HttpServlet { + private static final Logger log = LoggerFactory.getLogger(SignUpServlet.class); + + @Inject + private AccountService accountService; + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + log.debug("Sign-up data submitted; checking.."); + ValidationErrors errors = new ValidationErrors(); + try { + errors.append(accountService.signUp(request)); + if (errors.isEmpty()) { + log.debug("Sign-up successful; redirect to login page"); + LOGIN.redirect(request, response); + return; + } + log.debug("Sign-up form had invalid entries"); + } catch (Exception e) { + log.debug("Sign-up failed"); + errors.append(e.getMessage()); + } + + request.setAttribute("errors", errors); + SIGNUP.forward(getServletConfig().getServletContext(), request, response); + + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + SIGNUP.forward(getServletConfig().getServletContext(), request, response); + } } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginServlet.java index c52b27296..3c5dbf356 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LoginServlet.java @@ -28,6 +28,7 @@ import java.io.IOException; import static uk.ac.ebi.fg.annotare2.web.server.login.ServletNavigation.*; +import static uk.ac.ebi.fg.annotare2.web.server.login.SessionInformation.*; /** * @author Olga Melnichuk @@ -36,22 +37,26 @@ public class LoginServlet extends HttpServlet { private static final Logger log = LoggerFactory.getLogger(LoginServlet.class); + + @Inject - private AuthService authService; + private AccountService accountService; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("Login details submitted; validating.."); ValidationErrors errors = new ValidationErrors(); try { - errors.append(authService.login(request)); + errors.append(accountService.login(request)); + EMAIL_SESSION_ATTRIBUTE.set(request.getSession(), request.getParameter("email")); + if (errors.isEmpty()) { log.debug("Login details are valid; Authorization succeeded"); HOME.restoreAndRedirect(request, response); return; } log.debug("Login details are invalid"); - } catch (LoginException e) { + } catch (AccountServiceException e) { log.debug("Authorization failed"); errors.append(e.getMessage()); } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LogoutServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LogoutServlet.java index 8e790a28f..087a55e35 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LogoutServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/LogoutServlet.java @@ -32,11 +32,11 @@ public class LogoutServlet extends HttpServlet { @Inject - private AuthService authService; + private AccountService accountService; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - authService.logout(request.getSession()); + accountService.logout(request.getSession()); LOGIN.redirect(request, response); } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SecurityFilter.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SecurityFilter.java index 9df980706..6ab36c0f7 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SecurityFilter.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SecurityFilter.java @@ -37,7 +37,7 @@ public class SecurityFilter implements Filter { private static final Logger log = LoggerFactory.getLogger(SecurityFilter.class); @Inject - private AuthService authService; + private AccountService accountService; @Inject private AllRpcServicePaths rpcServicePaths; @@ -53,7 +53,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo if (servletRequest instanceof HttpServletRequest) { HttpServletRequest request = (HttpServletRequest) servletRequest; - if (!authService.isLoggedIn(request)) { + if (!accountService.isLoggedIn(request)) { forceLogin(request, (HttpServletResponse) servletResponse); return; } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ServletNavigation.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ServletNavigation.java index 075a185cb..41d35d90e 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ServletNavigation.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/ServletNavigation.java @@ -78,6 +78,12 @@ public void redirect(HttpServletRequest request, HttpServletResponse response) t sendRedirect(contextBasedUrl(redirectTo, request), response); } + public void redirect(HttpServletRequest request, HttpServletResponse response, String queryString) throws IOException { + String redirectUrl = redirectTo + ( isNullOrEmpty(queryString) ? "" : "?" + queryString ); + log.debug("Redirecting to {}", redirectUrl); + sendRedirect(contextBasedUrl(redirectUrl, request), response); + } + public void forward(ServletContext context, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.debug("Forwarding to {}", forwardTo); context.getRequestDispatcher(preserveCodeSrvParam(forwardTo, request)).forward(request, response); diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpService.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SessionInformation.java similarity index 69% rename from app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpService.java rename to app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SessionInformation.java index 3b97abb46..1e69d7e72 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpService.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SessionInformation.java @@ -17,10 +17,9 @@ * */ -import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; +import uk.ac.ebi.fg.annotare2.web.server.login.utils.SessionAttribute; -import javax.servlet.http.HttpServletRequest; - -public interface SignUpService { - public ValidationErrors signUp(HttpServletRequest request) throws Exception; +public class SessionInformation { + public static final SessionAttribute EMAIL_SESSION_ATTRIBUTE = new SessionAttribute("email"); + public static final SessionAttribute INFO_SESSION_ATTRIBUTE = new SessionAttribute("info"); } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServiceImpl.java deleted file mode 100644 index db478ed65..000000000 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServiceImpl.java +++ /dev/null @@ -1,107 +0,0 @@ -package uk.ac.ebi.fg.annotare2.web.server.login; - -/* - * Copyright 2009-2013 European Molecular Biology Laboratory - * - * 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. - * - */ - -import com.google.common.collect.ImmutableMap; -import com.google.inject.Inject; -import uk.ac.ebi.fg.annotare2.db.om.User; -import uk.ac.ebi.fg.annotare2.web.server.login.utils.RequestParam; -import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; -import uk.ac.ebi.fg.annotare2.web.server.services.AccountManager; -import uk.ac.ebi.fg.annotare2.web.server.services.EmailSender; -import uk.ac.ebi.fg.annotare2.web.server.transaction.Transactional; - -import javax.servlet.http.HttpServletRequest; - -import static java.util.Arrays.asList; - -public class SignUpServiceImpl implements SignUpService { - - @Inject - private AccountManager manager; - - @Inject - private EmailSender emailer; - - @Transactional - public ValidationErrors signUp(HttpServletRequest request) throws Exception { - SignUpParams params = new SignUpParams(request); - ValidationErrors errors = params.validate(); - if (errors.isEmpty()) { - if (null != manager.getByEmail(params.getEmail())) { - errors.append("email", "User with this email already exists"); - } else { - User u = manager.createUser(params.getName(), params.getEmail(), params.getPassword()); - emailer.sendFromTemplate( - EmailSender.NEW_USER_TEMPLATE, - ImmutableMap.of( - "to.name", u.getName(), - "to.email", u.getEmail(), - "verification.token", u.getVerificationToken() - ) - ); - } - } - return errors; - - } - - static class SignUpParams { - public static final String NAME_PARAM = "name"; - public static final String EMAIL_PARAM = "email"; - public static final String PASSWORD_PARAM = "password"; - public static final String CONFIRM_PASSWORD_PARAM = "confirm-password"; - - private final RequestParam name; - private final RequestParam email; - private final RequestParam password; - private final RequestParam confirmPassword; - - private SignUpParams(HttpServletRequest request) { - name = RequestParam.from(request, NAME_PARAM); - email = RequestParam.from(request, EMAIL_PARAM); - password = RequestParam.from(request, PASSWORD_PARAM); - confirmPassword = RequestParam.from(request, CONFIRM_PASSWORD_PARAM); - } - - public ValidationErrors validate() { - ValidationErrors errors = new ValidationErrors(); - for (RequestParam p : asList(name, email, password)) { - if (p.isEmpty()) { - errors.append(p.getName(), "Field \"" + p.getName() + "\" is required"); - } - } - if (!password.getValue().equals(confirmPassword.getValue())) { - errors.append(confirmPassword.getName(), "Passwords do not match"); - } - return errors; - } - - public String getName() { - return name.getValue(); - } - - public String getEmail() { - return email.getValue(); - } - - public String getPassword() { - return password.getValue(); - } - } -} diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServlet.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServlet.java index bd2cbf9f1..5174f0f3e 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServlet.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/SignUpServlet.java @@ -29,26 +29,30 @@ import java.io.IOException; import static uk.ac.ebi.fg.annotare2.web.server.login.ServletNavigation.*; +import static uk.ac.ebi.fg.annotare2.web.server.login.SessionInformation.*; public class SignUpServlet extends HttpServlet { - private static final Logger log = LoggerFactory.getLogger(LoginServlet.class); + private static final Logger log = LoggerFactory.getLogger(SignUpServlet.class); @Inject - private SignUpService signUpService; + private AccountService accountService; @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.debug("Sign-up data submitted; checking.."); ValidationErrors errors = new ValidationErrors(); try { - errors.append(signUpService.signUp(request)); + errors.append(accountService.signUp(request)); if (errors.isEmpty()) { log.debug("Sign-up successful; redirect to login page"); + EMAIL_SESSION_ATTRIBUTE.set(request.getSession(), request.getParameter("email")); + INFO_SESSION_ATTRIBUTE.set(request.getSession(), "You have been successfully registered; please sign in now"); LOGIN.redirect(request, response); return; + } else { + log.debug("Sign-up form had invalid entries"); } - log.debug("Sign-up form had invalid entries"); - } catch (Exception e) { + } catch (AccountServiceException e) { log.debug("Sign-up failed"); errors.append(e.getMessage()); } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/utils/ValidationErrors.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/utils/ValidationErrors.java index 6ded2824d..76b9d3ae2 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/utils/ValidationErrors.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/login/utils/ValidationErrors.java @@ -53,7 +53,7 @@ public String getErrors() { public String getErrors(String name) { Collection<String> err = errors.get(name); - return err == null ? "" : on(",").join(err); + return err == null ? "" : on(", ").join(err); } } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AdfServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AdfServiceImpl.java index cdfaaf92e..a5ed87ce2 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AdfServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AdfServiceImpl.java @@ -35,7 +35,7 @@ import uk.ac.ebi.fg.annotare2.web.gwt.common.client.DataImportException; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.NoPermissionException; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.ResourceNotFoundException; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; import uk.ac.ebi.fg.annotare2.web.server.services.UploadedFiles; @@ -51,8 +51,8 @@ public class AdfServiceImpl extends SubmissionBasedRemoteService implements AdfS private static final Logger log = LoggerFactory.getLogger(AdfServiceImpl.class); @Inject - public AdfServiceImpl(AuthService authService, SubmissionManager submissionManager) { - super(authService, submissionManager); + public AdfServiceImpl(AccountService accountService, SubmissionManager submissionManager) { + super(accountService, submissionManager); } @Transactional diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AuthBasedRemoteService.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AuthBasedRemoteService.java index 79b4f2c0d..f42fd51ce 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AuthBasedRemoteService.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/AuthBasedRemoteService.java @@ -18,7 +18,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet; import uk.ac.ebi.fg.annotare2.db.om.User; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import javax.servlet.http.HttpSession; @@ -27,14 +27,14 @@ */ abstract class AuthBasedRemoteService extends RemoteServiceServlet { - private final AuthService authService; + private final AccountService accountService; - public AuthBasedRemoteService(AuthService authService) { - this.authService = authService; + public AuthBasedRemoteService(AccountService accountService) { + this.accountService = accountService; } protected User getCurrentUser() { - return authService.getCurrentUser(getSession()); + return accountService.getCurrentUser(getSession()); } protected HttpSession getSession() { diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/CurrentUserAccountServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/CurrentUserAccountServiceImpl.java index d8a7b2525..a18d786c4 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/CurrentUserAccountServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/CurrentUserAccountServiceImpl.java @@ -19,7 +19,7 @@ import com.google.inject.Inject; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.CurrentUserAccountService; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.dto.UserDto; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.transaction.Transactional; import static uk.ac.ebi.fg.annotare2.web.server.rpc.transform.UIObjectConverter.uiUser; @@ -30,8 +30,8 @@ public class CurrentUserAccountServiceImpl extends AuthBasedRemoteService implements CurrentUserAccountService { @Inject - public CurrentUserAccountServiceImpl(AuthService authService) { - super(authService); + public CurrentUserAccountServiceImpl(AccountService accountService) { + super(accountService); } @Transactional diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionBasedRemoteService.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionBasedRemoteService.java index da6e8677a..a9ce8b65c 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionBasedRemoteService.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionBasedRemoteService.java @@ -26,7 +26,7 @@ import uk.ac.ebi.fg.annotare2.db.om.enums.Permission; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.NoPermissionException; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.ResourceNotFoundException; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; @@ -39,9 +39,9 @@ public abstract class SubmissionBasedRemoteService extends AuthBasedRemoteServic private final SubmissionManager submissionManager; - protected SubmissionBasedRemoteService(AuthService authService, + protected SubmissionBasedRemoteService(AccountService accountService, SubmissionManager submissionManager) { - super(authService); + super(accountService); this.submissionManager = submissionManager; } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionListServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionListServiceImpl.java index b4cc0835e..1e5583edf 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionListServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionListServiceImpl.java @@ -20,7 +20,7 @@ import uk.ac.ebi.fg.annotare2.db.om.Submission; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.SubmissionListService; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.SubmissionRow; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.rpc.transform.UIObjectConverter; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; import uk.ac.ebi.fg.annotare2.web.server.transaction.Transactional; @@ -38,8 +38,8 @@ public class SubmissionListServiceImpl extends AuthBasedRemoteService implements private final SubmissionManager submissionManager; @Inject - public SubmissionListServiceImpl(AuthService authService, SubmissionManager submissionManager) { - super(authService); + public SubmissionListServiceImpl(AccountService accountService, SubmissionManager submissionManager) { + super(accountService); this.submissionManager = submissionManager; } diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionServiceImpl.java index 288acf37f..c7e54d0f8 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionServiceImpl.java @@ -46,7 +46,7 @@ import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.update.ArrayDesignUpdateCommand; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.update.ArrayDesignUpdateResult; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.update.ExperimentUpdateCommand; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.properties.AnnotareProperties; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.DataFileManager; @@ -81,12 +81,12 @@ public class SubmissionServiceImpl extends SubmissionBasedRemoteService implemen private final UserDao userDao; @Inject - public SubmissionServiceImpl(AuthService authService, + public SubmissionServiceImpl(AccountService accountService, SubmissionManager submissionManager, DataFileManager dataFileManager, AnnotareProperties properties, UserDao userDao) { - super(authService, submissionManager); + super(accountService, submissionManager); this.dataFileManager = dataFileManager; this.properties = properties; this.userDao = userDao; diff --git a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionValidationServiceImpl.java b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionValidationServiceImpl.java index e06b59a52..c28d5901c 100644 --- a/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionValidationServiceImpl.java +++ b/app/web/src/main/java/uk/ac/ebi/fg/annotare2/web/server/rpc/SubmissionValidationServiceImpl.java @@ -30,7 +30,7 @@ import uk.ac.ebi.fg.annotare2.web.gwt.common.client.ResourceNotFoundException; import uk.ac.ebi.fg.annotare2.web.gwt.common.client.SubmissionValidationService; import uk.ac.ebi.fg.annotare2.web.gwt.common.shared.ValidationResult; -import uk.ac.ebi.fg.annotare2.web.server.login.AuthService; +import uk.ac.ebi.fg.annotare2.web.server.login.AccountService; import uk.ac.ebi.fg.annotare2.web.server.services.AccessControlException; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionManager; import uk.ac.ebi.fg.annotare2.web.server.services.SubmissionValidator; @@ -52,10 +52,10 @@ public class SubmissionValidationServiceImpl extends SubmissionBasedRemoteServic private final SubmissionValidator validator; @Inject - public SubmissionValidationServiceImpl(AuthService authService, + public SubmissionValidationServiceImpl(AccountService accountService, SubmissionManager submissionManager, SubmissionValidator validator) { - super(authService, submissionManager); + super(accountService, submissionManager); this.validator = validator; } diff --git a/app/web/src/main/webapp/login.css b/app/web/src/main/webapp/login.css index 32f3373af..386e086ac 100644 --- a/app/web/src/main/webapp/login.css +++ b/app/web/src/main/webapp/login.css @@ -38,6 +38,12 @@ text-align: left; } +.info { + font-size: small; + color: darkgreen; + text-align: left; +} + .form { border-collapse: collapse; color: #000; diff --git a/app/web/src/main/webapp/login.jsp b/app/web/src/main/webapp/login.jsp index 9d344e7a3..c1e1537ac 100644 --- a/app/web/src/main/webapp/login.jsp +++ b/app/web/src/main/webapp/login.jsp @@ -25,8 +25,11 @@ pageContext.setAttribute("passwordErrors", errors.getErrors("password")); } - String[] values = request.getParameterValues("email"); - pageContext.setAttribute("email", values == null ? "" : values[0]); + String email = request.getParameter("email"); + if (null == email) { + email = (String)session.getAttribute("email"); + } + pageContext.setAttribute("email", email == null ? "" : email); %> <!DOCTYPE html> <html> @@ -48,13 +51,27 @@ <td></td> <td><h1>Annotare 2.0</h1></td> </tr> + <tr class="info"> + <td></td> + <td><c:out value="${sessionScope.info}" /><c:remove var="info" scope="session" /></td> + + </tr> <tr class="error"> <td></td> <td>${dummyErrors}</td> </tr> <tr class="row right"> <td>Email address</td> - <td><input type="text" name="email" value="${email}" style="width:98%"/></td> + <td> + <c:choose> + <c:when test="${email != ''}"> + <input type="text" name="email" value="${email}" style="width:98%"/> + </c:when> + <c:otherwise> + <input type="text" name="email" style="width:98%" autofocus="autofocus"/> + </c:otherwise> + </c:choose> + </td> </tr> <tr class="error"> <td></td> @@ -62,7 +79,16 @@ </tr> <tr class="row right"> <td>Password</td> - <td><input type="password" name="password" style="width:98%"/></td> + <td> + <c:choose> + <c:when test="${email != ''}"> + <input type="password" name="password" style="width:98%" autofocus="autofocus"/> + </c:when> + <c:otherwise> + <input type="password" name="password" style="width:98%"/> + </c:otherwise> + </c:choose> + </td> </tr> <tr class="error"> <td></td> diff --git a/app/web/src/main/webapp/sign-up.jsp b/app/web/src/main/webapp/sign-up.jsp index b372c818d..a19f606a2 100644 --- a/app/web/src/main/webapp/sign-up.jsp +++ b/app/web/src/main/webapp/sign-up.jsp @@ -34,7 +34,6 @@ values = request.getParameterValues("email"); pageContext.setAttribute("email", values == null ? "" : values[0]); - %> <!DOCTYPE html> <html> diff --git a/app/web/src/test/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthenticationServiceImplTest.java b/app/web/src/test/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthenticationServiceImplTest.java index 68f8858e3..b4fa7e101 100644 --- a/app/web/src/test/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthenticationServiceImplTest.java +++ b/app/web/src/test/java/uk/ac/ebi/fg/annotare2/web/server/login/AuthenticationServiceImplTest.java @@ -19,6 +19,7 @@ import org.junit.Test; import uk.ac.ebi.fg.annotare2.web.server.services.AccountManager; import uk.ac.ebi.fg.annotare2.web.server.login.utils.ValidationErrors; +import uk.ac.ebi.fg.annotare2.web.server.services.EmailSender; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -37,13 +38,14 @@ public void testExistedLogin() { final String password = "existed_password"; AccountManager accMan = mockAccManager(name, password, true); + EmailSender emailer = mockEmailer(); HttpServletRequest request = mockRequest(name, password); try { - AuthService authService = new AuthServiceImpl(accMan); - ValidationErrors errors = authService.login(request); + AccountService accountService = new AccountServiceImpl(accMan, emailer); + ValidationErrors errors = accountService.login(request); assertTrue(errors.isEmpty()); - } catch (LoginException e) { + } catch (AccountServiceException e) { fail("Existed user should be logged in"); } } @@ -54,40 +56,41 @@ public void testNonExistedLogin() { final String password = "non_existed_password"; AccountManager accMan = mockAccManager(name, password, false); + EmailSender emailer = mockEmailer(); HttpServletRequest request = mockRequest(name, password); try { - AuthService authService = new AuthServiceImpl(accMan); - authService.login(request); + AccountService accountService = new AccountServiceImpl(accMan, emailer); + accountService.login(request); fail("Non-existed user should not be logged in"); - } catch (LoginException e) { + } catch (AccountServiceException e) { //ok } } @Test - public void testInvalidLogin() throws LoginException { - AuthService authService = new AuthServiceImpl(null); + public void testInvalidLogin() throws AccountServiceException { + AccountService accountService = new AccountServiceImpl(null, null); HttpServletRequest request = mockRequest("user", null); - ValidationErrors errors = authService.login(request); + ValidationErrors errors = accountService.login(request); assertFalse(errors.isEmpty()); - assertFalse(errors.getErrors(AuthServiceImpl.LoginParams.PASSWORD_PARAM).isEmpty()); + assertFalse(errors.getErrors(AccountServiceImpl.LoginParams.PASSWORD_PARAM).isEmpty()); request = mockRequest("user", ""); - errors = authService.login(request); + errors = accountService.login(request); assertFalse(errors.isEmpty()); - assertFalse(errors.getErrors(AuthServiceImpl.LoginParams.PASSWORD_PARAM).isEmpty()); + assertFalse(errors.getErrors(AccountServiceImpl.LoginParams.PASSWORD_PARAM).isEmpty()); request = mockRequest(null, "password"); - errors = authService.login(request); + errors = accountService.login(request); assertFalse(errors.isEmpty()); - assertFalse(errors.getErrors(AuthServiceImpl.LoginParams.EMAIL_PARAM).isEmpty()); + assertFalse(errors.getErrors(AccountServiceImpl.LoginParams.EMAIL_PARAM).isEmpty()); request = mockRequest("", "password"); - errors = authService.login(request); + errors = accountService.login(request); assertFalse(errors.isEmpty()); - assertFalse(errors.getErrors(AuthServiceImpl.LoginParams.EMAIL_PARAM).isEmpty()); + assertFalse(errors.getErrors(AccountServiceImpl.LoginParams.EMAIL_PARAM).isEmpty()); } private AccountManager mockAccManager(String user, String password, boolean exists) { @@ -97,6 +100,11 @@ private AccountManager mockAccManager(String user, String password, boolean exis return accMan; } + private EmailSender mockEmailer() { + EmailSender emailer = createMock(EmailSender.class); + return emailer; + } + private HttpServletRequest mockRequest(String name, String password) { HttpSession session = createMock(HttpSession.class); session.setAttribute(isA(String.class), isA(Object.class)); @@ -104,11 +112,11 @@ private HttpServletRequest mockRequest(String name, String password) { HttpServletRequest request = createMock(HttpServletRequest.class); expect(request - .getParameterValues(AuthServiceImpl.LoginParams.EMAIL_PARAM)) + .getParameterValues(AccountServiceImpl.LoginParams.EMAIL_PARAM)) .andReturn(name == null ? null : new String[]{name}).anyTimes(); expect(request - .getParameterValues(AuthServiceImpl.LoginParams.PASSWORD_PARAM)) + .getParameterValues(AccountServiceImpl.LoginParams.PASSWORD_PARAM)) .andReturn(password == null ? null : new String[]{password}).anyTimes(); expect(request.getSession()).andReturn(session).anyTimes();
91b74931a3d858645cf106295090a11e803c3e83
elasticsearch
[TEST] Stabelize MoreLikeThisActionTests--The `testCompareMoreLikeThisDSLWithAPI` test compares results from query-and API which might query different shards. Those shares might use-different doc IDs internally to disambiguate. This commit resorts the-results and compares them after stable disambiguation.-
c
https://github.com/elastic/elasticsearch
diff --git a/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java b/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java index 19c577fd1d2ca..1ea485a3c437b 100644 --- a/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java +++ b/src/test/java/org/elasticsearch/mlt/MoreLikeThisActionTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.mlt; +import org.apache.lucene.util.ArrayUtil; import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder; @@ -37,6 +38,7 @@ import org.junit.Test; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import static org.elasticsearch.client.Requests.*; @@ -407,17 +409,33 @@ public void testCompareMoreLikeThisDSLWithAPI() throws Exception { .setSearchType(SearchType.QUERY_THEN_FETCH) .setTypes("type1") .setQuery(queryBuilder) + .setSize(texts.length) .execute().actionGet(); assertSearchResponse(mltResponseDSL); logger.info("Running MoreLikeThis API"); - MoreLikeThisRequest mltRequest = moreLikeThisRequest("test").type("type1").id("0").minTermFreq(1).minDocFreq(1); + MoreLikeThisRequest mltRequest = moreLikeThisRequest("test").type("type1").searchSize(texts.length).id("0").minTermFreq(1).minDocFreq(1); SearchResponse mltResponseAPI = client.moreLikeThis(mltRequest).actionGet(); assertSearchResponse(mltResponseAPI); logger.info("Ensure the documents and scores returned are the same."); SearchHit[] hitsDSL = mltResponseDSL.getHits().hits(); SearchHit[] hitsAPI = mltResponseAPI.getHits().hits(); + + // we have to resort since the results might come from + // different shards and docIDs that are used for tie-breaking might not be the same on the shards + Comparator<SearchHit> cmp = new Comparator<SearchHit>() { + + @Override + public int compare(SearchHit o1, SearchHit o2) { + if (Float.compare(o1.getScore(), o2.getScore()) == 0) { + return o1.getId().compareTo(o2.getId()); + } + return Float.compare(o1.getScore(), o2.getScore()); + } + }; + ArrayUtil.timSort(hitsDSL, cmp); + ArrayUtil.timSort(hitsAPI, cmp); assertThat("Not the same number of results.", hitsAPI.length, equalTo(hitsDSL.length)); for (int i = 0; i < hitsDSL.length; i++) { assertThat("Expected id: " + hitsDSL[i].getId() + " at position " + i + " but wasn't.",
42fa86735cb89bdde76545946d154c045513c12b
Delta Spike
DELTASPIKE-277 fix JsfMessageProducer
c
https://github.com/apache/deltaspike
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java index af4bd70e5..6dc58b8a7 100644 --- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java +++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/message/JsfMessageProducer.java @@ -34,12 +34,12 @@ public class JsfMessageProducer { @Produces @Dependent - public JsfMessage<?> createJsfMessage(InjectionPoint injectionPoint) + public JsfMessage createJsfMessage(InjectionPoint injectionPoint) { return createJsfMessageFor(injectionPoint, ReflectionUtils.getRawType(injectionPoint.getType())); } - private JsfMessage<?> createJsfMessageFor(InjectionPoint injectionPoint, Class<Object> rawType) + private JsfMessage createJsfMessageFor(InjectionPoint injectionPoint, Class<Object> rawType) { //X TODO check if the JsfMessage should get injected into a UIComponent and use #getClientId()
7313d4beb806bc046636933119053bd0393d0d12
Vala
Add ScanfFormat to used attributes
a
https://github.com/GNOME/vala/
diff --git a/vala/valausedattr.vala b/vala/valausedattr.vala index 0fc5b45645..cdf895d5cc 100644 --- a/vala/valausedattr.vala +++ b/vala/valausedattr.vala @@ -57,6 +57,7 @@ public class Vala.UsedAttr : CodeVisitor { "BooleanType", "", "SimpleType", "", "PrintfFormat", "", + "ScanfFormat", "", "GIR", "name", ""
cf5fb324e3d006d4360c0ae1bba0b2f57d3b6097
restlet-framework-java
Updated Ranges test case.--
p
https://github.com/restlet/restlet-framework-java
diff --git a/modules/org.restlet.test/src/org/restlet/test/RangeTestCase.java b/modules/org.restlet.test/src/org/restlet/test/RangeTestCase.java index 81b1fa31fb..6846d24ed0 100644 --- a/modules/org.restlet.test/src/org/restlet/test/RangeTestCase.java +++ b/modules/org.restlet.test/src/org/restlet/test/RangeTestCase.java @@ -103,7 +103,7 @@ public void handle(Request request, Response response) { String[] tab = value.split("-"); if (tab.length == 2) { index = Long.parseLong(tab[0]); - length = index + Long.parseLong(tab[1]); + length = Long.parseLong(tab[1]) - index; } } @@ -182,7 +182,6 @@ public void testRanges() { assertEquals(Status.SUCCESS_OK, client.handle(request).getStatus()); // Test partial Get. -/* request = new Request(Method.GET, "http://localhost:8182/testGet"); Response response = client.handle(request); assertEquals(Status.SUCCESS_OK, response.getStatus()); @@ -199,12 +198,12 @@ public void testRanges() { assertEquals(Status.SUCCESS_OK, response.getStatus()); assertEquals("12", response.getEntity().getText()); - request.setRanges(Arrays.asList(new Range(3, 2))); + request.setRanges(Arrays.asList(new Range(2, 2))); response = client.handle(request); assertEquals(Status.SUCCESS_OK, response.getStatus()); assertEquals("34", response.getEntity().getText()); - request.setRanges(Arrays.asList(new Range(3, 7))); + request.setRanges(Arrays.asList(new Range(2, 7))); response = client.handle(request); assertEquals(Status.SUCCESS_OK, response.getStatus()); assertEquals("3456789", response.getEntity().getText()); @@ -213,7 +212,7 @@ public void testRanges() { response = client.handle(request); assertEquals(Status.SUCCESS_OK, response.getStatus()); assertEquals("4567890", response.getEntity().getText()); -*/ + component.stop(); } catch (Exception e) { e.printStackTrace();
3b4f5d617969bc4d6bda9f0da17a141cb32bd521
camel
CAMEL-939 - Fix csv test that fails on slower- machines sometimes.--git-svn-id: https://svn.apache.org/repos/asf/activemq/camel/trunk@700232 13f79535-47bb-0310-9956-ffa450edef68-
c
https://github.com/apache/camel
diff --git a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java index 5c0c336a6720c..e4ea16d6cc753 100644 --- a/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java +++ b/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java @@ -70,7 +70,11 @@ public void testSendMessage() throws Exception { log.debug("Received " + text); assertNotNull("Should be able to convert received body to a string", text); - assertEquals("text body", "abc,123", text.trim()); + + // order is not guaranteed with a Map (which was passed in before) + // so we need to check for both combinations + assertTrue("Text body has wrong value.", "abc,123".equals(text.trim()) + || "123,abc".equals(text.trim())); } }
319b1c8ad41b769ff4bc5d8cb2d2eb9e3f5e9569
orientdb
Minor: fixed javadoc
c
https://github.com/orientechnologies/orientdb
diff --git a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java index a917b02364d..4129b9cd427 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java +++ b/core/src/main/java/com/orientechnologies/orient/core/metadata/schema/OSchemaShared.java @@ -451,7 +451,7 @@ public void changeClassName(String iOldName, String iNewName) { @Override public void fromStream() { // READ CURRENT SCHEMA VERSION - Integer schemaVersion = (Integer) document.field("schemaVersion"); + final Integer schemaVersion = (Integer) document.field("schemaVersion"); if (schemaVersion == null) { OLogManager .instance() diff --git a/core/src/main/java/com/orientechnologies/orient/core/processor/block/OExecuteBlock.java b/core/src/main/java/com/orientechnologies/orient/core/processor/block/OExecuteBlock.java index 32e5490f405..d362d20134b 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/processor/block/OExecuteBlock.java +++ b/core/src/main/java/com/orientechnologies/orient/core/processor/block/OExecuteBlock.java @@ -112,10 +112,13 @@ private Object executeBlock(OComposableProcessor iManager, final OCommandContext merge = Boolean.FALSE; Object result; - if (isBlock(iValue)) + if (isBlock(iValue)) { // EXECUTE SINGLE BLOCK - result = delegate(iName, iManager, (ODocument) iValue, iContext, iOutput, iReadOnly); - else { + final ODocument value = (ODocument) iValue; + result = delegate(iName, iManager, value, iContext, iOutput, iReadOnly); + if (value.containsField("return")) + return returnValue; + } else { // EXECUTE ENTIRE PROCESS try { result = iManager.processFromFile(iName, iContext, iReadOnly); diff --git a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostBatch.java b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostBatch.java index dac2e488b04..8aa9509e2f0 100644 --- a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostBatch.java +++ b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/http/command/post/OServerCommandPostBatch.java @@ -26,9 +26,9 @@ import com.orientechnologies.orient.server.network.protocol.http.command.OServerCommandDocumentAbstract; /** - * Execute a batch of commands in one shot. This is useful to reduce network latency issuing multiple commands as multiple request. - * Batch command supports transactions.<br> - * Format: { "transaction" : <true|false>, "operations" : [ { "type" : "<type>" }* ] }<br> + * Executes a batch of operations in a single call. This is useful to reduce network latency issuing multiple commands as multiple + * requests. Batch command supports transactions as well.<br><br> + * Format: { "transaction" : &lt;true|false&gt;, "operations" : [ { "type" : "&lt;type&gt;" }* ] }<br> * Where: * <ul> * <li><b>type</b> can be:
a429e230b632c40cf3167cbac54ea87b6ad87297
spring-framework
revised version checks and exception signatures--
p
https://github.com/spring-projects/spring-framework
diff --git a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/DispatcherPortlet.java b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/DispatcherPortlet.java index d784450b6726..878053a0eb31 100644 --- a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/DispatcherPortlet.java +++ b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/DispatcherPortlet.java @@ -42,7 +42,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -583,10 +582,9 @@ protected <T> List<T> getDefaultStrategies(ApplicationContext context, Class<T> * @param context the current Portlet ApplicationContext * @param clazz the strategy implementation class to instantiate * @return the fully configured strategy instance - * @throws BeansException if initialization failed * @see org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory() */ - protected Object createDefaultStrategy(ApplicationContext context, Class<?> clazz) throws BeansException { + protected Object createDefaultStrategy(ApplicationContext context, Class<?> clazz) { return context.getAutowireCapableBeanFactory().createBean(clazz); } diff --git a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/FrameworkPortlet.java b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/FrameworkPortlet.java index 75cad59c52e2..3ddac18c10db 100644 --- a/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/FrameworkPortlet.java +++ b/org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/FrameworkPortlet.java @@ -32,7 +32,6 @@ import javax.portlet.ResourceResponse; import org.springframework.beans.BeanUtils; -import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.ApplicationListener; @@ -258,7 +257,7 @@ public void setUserinfoUsernameAttributes(String[] userinfoUsernameAttributes) { * have been set. Creates this portlet's ApplicationContext. */ @Override - protected final void initPortletBean() throws PortletException, BeansException { + protected final void initPortletBean() throws PortletException { getPortletContext().log("Initializing Spring FrameworkPortlet '" + getPortletName() + "'"); if (logger.isInfoEnabled()) { logger.info("FrameworkPortlet '" + getPortletName() + "': initialization started"); @@ -273,7 +272,7 @@ protected final void initPortletBean() throws PortletException, BeansException { logger.error("Context initialization failed", ex); throw ex; } - catch (BeansException ex) { + catch (RuntimeException ex) { logger.error("Context initialization failed", ex); throw ex; } @@ -289,9 +288,8 @@ protected final void initPortletBean() throws PortletException, BeansException { * <p>Delegates to {@link #createPortletApplicationContext} for actual creation. * Can be overridden in subclasses. * @return the ApplicationContext for this portlet - * @throws BeansException if the context couldn't be initialized */ - protected ApplicationContext initPortletApplicationContext() throws BeansException { + protected ApplicationContext initPortletApplicationContext() { ApplicationContext parent = PortletApplicationContextUtils.getWebApplicationContext(getPortletContext()); ApplicationContext pac = createPortletApplicationContext(parent); @@ -320,13 +318,10 @@ protected ApplicationContext initPortletApplicationContext() throws BeansExcepti * ConfigurablePortletApplicationContext. Can be overridden in subclasses. * @param parent the parent ApplicationContext to use, or null if none * @return the Portlet ApplicationContext for this portlet - * @throws BeansException if the context couldn't be initialized * @see #setContextClass * @see org.springframework.web.portlet.context.XmlPortletApplicationContext */ - protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) - throws BeansException { - + protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) { Class<?> contextClass = getContextClass(); if (logger.isDebugEnabled()) { logger.debug("Portlet with name '" + getPortletName() + @@ -338,7 +333,6 @@ protected ApplicationContext createPortletApplicationContext(ApplicationContext "': custom ApplicationContext class [" + contextClass.getName() + "] is not of type ConfigurablePortletApplicationContext"); } - ConfigurablePortletApplicationContext pac = (ConfigurablePortletApplicationContext) BeanUtils.instantiateClass(contextClass); @@ -400,19 +394,17 @@ public final ApplicationContext getPortletApplicationContext() { * <p>The default implementation is empty; subclasses may override this method * to perform any initialization they require. * @throws PortletException in case of an initialization exception - * @throws BeansException if thrown by ApplicationContext methods */ - protected void initFrameworkPortlet() throws PortletException, BeansException { + protected void initFrameworkPortlet() throws PortletException { } /** * Refresh this portlet's application context, as well as the * dependent state of the portlet. - * @throws BeansException in case of errors * @see #getPortletApplicationContext() * @see org.springframework.context.ConfigurableApplicationContext#refresh() */ - public void refresh() throws BeansException { + public void refresh() { ApplicationContext pac = getPortletApplicationContext(); if (!(pac instanceof ConfigurableApplicationContext)) { throw new IllegalStateException("Portlet ApplicationContext does not support refresh: " + pac); @@ -438,10 +430,9 @@ public void onApplicationEvent(ContextRefreshedEvent event) { * Called after successful context refresh. * <p>This implementation is empty. * @param context the current Portlet ApplicationContext - * @throws BeansException in case of errors * @see #refresh() */ - protected void onRefresh(ApplicationContext context) throws BeansException { + protected void onRefresh(ApplicationContext context) { // For subclasses: do nothing by default. } diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index d94b9907f841..e870cd5525f3 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -35,7 +35,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -322,7 +321,7 @@ public void setCleanupAfterInclude(boolean cleanupAfterInclude) { * This implementation calls {@link #initStrategies}. */ @Override - protected void onRefresh(ApplicationContext context) throws BeansException { + protected void onRefresh(ApplicationContext context) { initStrategies(context); } @@ -673,11 +672,10 @@ protected <T> List<T> getDefaultStrategies(ApplicationContext context, Class<T> * @param context the current WebApplicationContext * @param clazz the strategy implementation class to instantiate * @return the fully configured strategy instance - * @throws BeansException if initialization failed * @see org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory() * @see org.springframework.beans.factory.config.AutowireCapableBeanFactory#createBean */ - protected Object createDefaultStrategy(ApplicationContext context, Class clazz) throws BeansException { + protected Object createDefaultStrategy(ApplicationContext context, Class<?> clazz) { return context.getAutowireCapableBeanFactory().createBean(clazz); } @@ -742,7 +740,7 @@ protected void doDispatch(HttpServletRequest request, HttpServletResponse respon int interceptorIndex = -1; try { - ModelAndView mv = null; + ModelAndView mv; boolean errorView = false; try { @@ -1032,13 +1030,11 @@ protected ModelAndView processHandlerException(HttpServletRequest request, * @throws Exception if there's a problem rendering the view */ protected void render(ModelAndView mv, HttpServletRequest request, HttpServletResponse response) throws Exception { - // Determine locale for request and apply it to the response. Locale locale = this.localeResolver.resolveLocale(request); response.setLocale(locale); - View view = null; - + View view; if (mv.isReference()) { // We need to resolve the view name. view = resolveViewName(mv.getViewName(), mv.getModelInternal(), locale, request); @@ -1076,7 +1072,7 @@ protected String getDefaultViewName(HttpServletRequest request) throws Exception /** * Resolve the given view name into a View object (to be rendered). - * <p>Default implementations asks all ViewResolvers of this dispatcher. + * <p>The default implementations asks all ViewResolvers of this dispatcher. * Can be overridden for custom resolution strategies, potentially based on * specific model attributes or request parameters. * @param viewName the name of the view to resolve @@ -1088,9 +1084,7 @@ protected String getDefaultViewName(HttpServletRequest request) throws Exception * (typically in case of problems creating an actual View object) * @see ViewResolver#resolveViewName */ - protected View resolveViewName(String viewName, - Map<String, Object> model, - Locale locale, + protected View resolveViewName(String viewName, Map<String, Object> model, Locale locale, HttpServletRequest request) throws Exception { for (ViewResolver viewResolver : this.viewResolvers) { diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FrameworkServlet.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FrameworkServlet.java index 820cd0d702c8..f4fefa855519 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FrameworkServlet.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/FrameworkServlet.java @@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.beans.BeanUtils; -import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.ApplicationListener; @@ -297,7 +296,7 @@ public void setDispatchTraceRequest(boolean dispatchTraceRequest) { * have been set. Creates this servlet's WebApplicationContext. */ @Override - protected final void initServletBean() throws ServletException, BeansException { + protected final void initServletBean() throws ServletException { getServletContext().log("Initializing Spring FrameworkServlet '" + getServletName() + "'"); if (this.logger.isInfoEnabled()) { this.logger.info("FrameworkServlet '" + getServletName() + "': initialization started"); @@ -312,7 +311,7 @@ protected final void initServletBean() throws ServletException, BeansException { this.logger.error("Context initialization failed", ex); throw ex; } - catch (BeansException ex) { + catch (RuntimeException ex) { this.logger.error("Context initialization failed", ex); throw ex; } @@ -329,11 +328,10 @@ protected final void initServletBean() throws ServletException, BeansException { * <p>Delegates to {@link #createWebApplicationContext} for actual creation * of the context. Can be overridden in subclasses. * @return the WebApplicationContext instance - * @throws BeansException if the context couldn't be initialized * @see #setContextClass * @see #setContextConfigLocation */ - protected WebApplicationContext initWebApplicationContext() throws BeansException { + protected WebApplicationContext initWebApplicationContext() { WebApplicationContext wac = findWebApplicationContext(); if (wac == null) { // No fixed context defined for this servlet - create a local one. @@ -397,12 +395,9 @@ protected WebApplicationContext findWebApplicationContext() { * before returning the context instance. * @param parent the parent ApplicationContext to use, or <code>null</code> if none * @return the WebApplicationContext for this servlet - * @throws BeansException if the context couldn't be initialized * @see org.springframework.web.context.support.XmlWebApplicationContext */ - protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) - throws BeansException { - + protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) { Class<?> contextClass = getContextClass(); if (this.logger.isDebugEnabled()) { this.logger.debug("Servlet with name '" + getServletName() + @@ -415,26 +410,27 @@ protected WebApplicationContext createWebApplicationContext(WebApplicationContex "': custom WebApplicationContext class [" + contextClass.getName() + "] is not of type ConfigurableWebApplicationContext"); } - ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass); // Assign the best possible id value. - ServletContext servletContext = getServletContext(); - if (servletContext.getMajorVersion() > 2 || servletContext.getMinorVersion() >= 5) { - // Servlet 2.5's getContextPath available! - wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContext.getContextPath() + "/" + getServletName()); - } - else { + ServletContext sc = getServletContext(); + if (sc.getMajorVersion() == 2 && sc.getMinorVersion() < 5) { // Servlet <= 2.4: resort to name specified in web.xml, if any. - String servletContextName = servletContext.getServletContextName(); + String servletContextName = sc.getServletContextName(); if (servletContextName != null) { - wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContextName + "." + getServletName()); + wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContextName + + "." + getServletName()); } else { wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + getServletName()); } } + else { + // Servlet 2.5's getContextPath available! + wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + sc.getContextPath() + + "/" + getServletName()); + } wac.setParent(parent); wac.setServletContext(getServletContext()); @@ -485,19 +481,17 @@ public final WebApplicationContext getWebApplicationContext() { * the WebApplicationContext has been loaded. The default implementation is empty; * subclasses may override this method to perform any initialization they require. * @throws ServletException in case of an initialization exception - * @throws BeansException if thrown by ApplicationContext methods */ - protected void initFrameworkServlet() throws ServletException, BeansException { + protected void initFrameworkServlet() throws ServletException { } /** * Refresh this servlet's application context, as well as the * dependent state of the servlet. - * @throws BeansException in case of errors * @see #getWebApplicationContext() * @see org.springframework.context.ConfigurableApplicationContext#refresh() */ - public void refresh() throws BeansException { + public void refresh() { WebApplicationContext wac = getWebApplicationContext(); if (!(wac instanceof ConfigurableApplicationContext)) { throw new IllegalStateException("WebApplicationContext does not support refresh: " + wac); @@ -523,10 +517,9 @@ public void onApplicationEvent(ContextRefreshedEvent event) { * Called after successful context refresh. * <p>This implementation is empty. * @param context the current WebApplicationContext - * @throws BeansException in case of errors * @see #refresh() */ - protected void onRefresh(ApplicationContext context) throws BeansException { + protected void onRefresh(ApplicationContext context) { // For subclasses: do nothing by default. } @@ -540,7 +533,7 @@ protected void onRefresh(ApplicationContext context) throws BeansException { */ @Override protected final void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { processRequest(request, response); } @@ -551,7 +544,7 @@ protected final void doGet(HttpServletRequest request, HttpServletResponse respo */ @Override protected final void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { processRequest(request, response); } @@ -562,7 +555,7 @@ protected final void doPost(HttpServletRequest request, HttpServletResponse resp */ @Override protected final void doPut(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { processRequest(request, response); } @@ -573,7 +566,7 @@ protected final void doPut(HttpServletRequest request, HttpServletResponse respo */ @Override protected final void doDelete(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + throws ServletException, IOException { processRequest(request, response); } @@ -584,7 +577,9 @@ protected final void doDelete(HttpServletRequest request, HttpServletResponse re * @see #doService */ @Override - protected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doOptions(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + super.doOptions(request, response); if (this.dispatchOptionsRequest) { processRequest(request, response); @@ -597,7 +592,9 @@ protected void doOptions(HttpServletRequest request, HttpServletResponse respons * @see #doService */ @Override - protected void doTrace(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + protected void doTrace(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + super.doTrace(request, response); if (this.dispatchTraceRequest) { processRequest(request, response); @@ -715,7 +712,7 @@ protected String getUsernameForRequest(HttpServletRequest request) { * @see javax.servlet.http.HttpServlet#doPost */ protected abstract void doService(HttpServletRequest request, HttpServletResponse response) - throws Exception; + throws Exception; /** diff --git a/org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java b/org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java index d1336917cc2b..22345a31f0a1 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java +++ b/org.springframework.web/src/main/java/org/springframework/web/context/ContextLoader.java @@ -26,7 +26,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeanUtils; -import org.springframework.beans.BeansException; import org.springframework.beans.factory.access.BeanFactoryLocator; import org.springframework.beans.factory.access.BeanFactoryReference; import org.springframework.context.ApplicationContext; @@ -167,14 +166,10 @@ public class ContextLoader { * "{@link #CONFIG_LOCATION_PARAM contextConfigLocation}" context-params. * @param servletContext current servlet context * @return the new WebApplicationContext - * @throws IllegalStateException if there is already a root application context present - * @throws BeansException if the context failed to initialize * @see #CONTEXT_CLASS_PARAM * @see #CONFIG_LOCATION_PARAM */ - public WebApplicationContext initWebApplicationContext(ServletContext servletContext) - throws IllegalStateException, BeansException { - + public WebApplicationContext initWebApplicationContext(ServletContext servletContext) { if (servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE) != null) { throw new IllegalStateException( "Cannot initialize context because there is already a root application context present - " + @@ -229,32 +224,24 @@ public WebApplicationContext initWebApplicationContext(ServletContext servletCon * Can be overridden in subclasses. * <p>In addition, {@link #customizeContext} gets called prior to refreshing the * context, allowing subclasses to perform custom modifications to the context. - * @param servletContext current servlet context + * @param sc current servlet context * @param parent the parent ApplicationContext to use, or <code>null</code> if none * @return the root WebApplicationContext - * @throws BeansException if the context couldn't be initialized * @see ConfigurableWebApplicationContext */ - protected WebApplicationContext createWebApplicationContext( - ServletContext servletContext, ApplicationContext parent) throws BeansException { - - Class<?> contextClass = determineContextClass(servletContext); + protected WebApplicationContext createWebApplicationContext(ServletContext sc, ApplicationContext parent) { + Class<?> contextClass = determineContextClass(sc); if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) { throw new ApplicationContextException("Custom context class [" + contextClass.getName() + "] is not of type [" + ConfigurableWebApplicationContext.class.getName() + "]"); } - ConfigurableWebApplicationContext wac = (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass); // Assign the best possible id value. - if (servletContext.getMajorVersion() > 2 || servletContext.getMinorVersion() >= 5) { - // Servlet 2.5's getContextPath available! - wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContext.getContextPath()); - } - else { + if (sc.getMajorVersion() == 2 && sc.getMinorVersion() < 5) { // Servlet <= 2.4: resort to name specified in web.xml, if any. - String servletContextName = servletContext.getServletContextName(); + String servletContextName = sc.getServletContextName(); if (servletContextName != null) { wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + servletContextName); } @@ -262,13 +249,16 @@ protected WebApplicationContext createWebApplicationContext( wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX); } } + else { + // Servlet 2.5's getContextPath available! + wac.setId(ConfigurableWebApplicationContext.APPLICATION_CONTEXT_ID_PREFIX + sc.getContextPath()); + } wac.setParent(parent); - wac.setServletContext(servletContext); - wac.setConfigLocation(servletContext.getInitParameter(CONFIG_LOCATION_PARAM)); - customizeContext(servletContext, wac); + wac.setServletContext(sc); + wac.setConfigLocation(sc.getInitParameter(CONFIG_LOCATION_PARAM)); + customizeContext(sc, wac); wac.refresh(); - return wac; } @@ -277,11 +267,10 @@ protected WebApplicationContext createWebApplicationContext( * default XmlWebApplicationContext or a custom context class if specified. * @param servletContext current servlet context * @return the WebApplicationContext implementation class to use - * @throws ApplicationContextException if the context class couldn't be loaded * @see #CONTEXT_CLASS_PARAM * @see org.springframework.web.context.support.XmlWebApplicationContext */ - protected Class determineContextClass(ServletContext servletContext) throws ApplicationContextException { + protected Class<?> determineContextClass(ServletContext servletContext) { String contextClassName = servletContext.getInitParameter(CONTEXT_CLASS_PARAM); if (contextClassName != null) { try { @@ -336,12 +325,9 @@ protected void customizeContext( * which also use the same configuration parameters. * @param servletContext current servlet context * @return the parent application context, or <code>null</code> if none - * @throws BeansException if the context couldn't be initialized * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator */ - protected ApplicationContext loadParentContext(ServletContext servletContext) - throws BeansException { - + protected ApplicationContext loadParentContext(ServletContext servletContext) { ApplicationContext parentContext = null; String locatorFactorySelector = servletContext.getInitParameter(LOCATOR_FACTORY_SELECTOR_PARAM); String parentContextKey = servletContext.getInitParameter(LOCATOR_FACTORY_KEY_PARAM);
4a29e164a8ca222fd8b0d2043e1d44494e84544e
spring-framework
Allow binary messages in StompSubProtocolHandler--Issue: SPR-12301-
a
https://github.com/spring-projects/spring-framework
diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java index e50637e0f013..d90328715398 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/StompSubProtocolHandler.java @@ -49,6 +49,7 @@ import org.springframework.messaging.support.MessageHeaderAccessor; import org.springframework.messaging.support.MessageHeaderInitializer; import org.springframework.util.Assert; +import org.springframework.web.socket.BinaryMessage; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketMessage; @@ -186,9 +187,16 @@ public void handleMessageFromClient(WebSocketSession session, List<Message<byte[]>> messages; try { - Assert.isInstanceOf(TextMessage.class, webSocketMessage); - TextMessage textMessage = (TextMessage) webSocketMessage; - ByteBuffer byteBuffer = ByteBuffer.wrap(textMessage.asBytes()); + ByteBuffer byteBuffer; + if (webSocketMessage instanceof TextMessage) { + byteBuffer = ByteBuffer.wrap(((TextMessage) webSocketMessage).asBytes()); + } + else if (webSocketMessage instanceof BinaryMessage) { + byteBuffer = ((BinaryMessage) webSocketMessage).getPayload(); + } + else { + throw new IllegalArgumentException("Unexpected WebSocket message type: " + webSocketMessage); + } BufferingStompDecoder decoder = this.decoders.get(session.getId()); if (decoder == null) {
77f3ff5cfc41f43bc51c3ce4505ff1a1aa80e2f1
Search_api
Issue #1064520 by drunken monkey: Added a processor for highlighting.
a
https://github.com/lucidworks/drupal_search_api
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 6e8d250b..2875d5b5 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,6 @@ Search API 1.x, dev (xx/xx/xxxx): --------------------------------- +- #1064520 by drunken monkey: Added a processor for highlighting. Search API 1.7 (07/01/2013): ---------------------------- diff --git a/search_api.info b/search_api.info index bcb88cd3..c03de9d0 100644 --- a/search_api.info +++ b/search_api.info @@ -21,6 +21,7 @@ files[] = includes/datasource_external.inc files[] = includes/exception.inc files[] = includes/index_entity.inc files[] = includes/processor.inc +files[] = includes/processor_highlight.inc files[] = includes/processor_html_filter.inc files[] = includes/processor_ignore_case.inc files[] = includes/processor_stopwords.inc diff --git a/search_api.module b/search_api.module index 52093680..9b8593bb 100644 --- a/search_api.module +++ b/search_api.module @@ -890,7 +890,7 @@ function search_api_search_api_alter_callback_info() { function search_api_search_api_processor_info() { $processors['search_api_case_ignore'] = array( 'name' => t('Ignore case'), - 'description' => t('This processor will make searches case-insensitive for all fulltext fields (and, optionally, also for filters on string fields).'), + 'description' => t('This processor will make searches case-insensitive for fulltext or string fields.'), 'class' => 'SearchApiIgnoreCase', ); $processors['search_api_html_filter'] = array( @@ -924,6 +924,12 @@ function search_api_search_api_processor_info() { 'class' => 'SearchApiStopWords', 'weight' => 30, ); + $processors['search_api_highlighting'] = array( + 'name' => t('Highlighting'), + 'description' => t('Adds highlighting for search results.'), + 'class' => 'SearchApiHighlight', + 'weight' => 35, + ); return $processors; }
8ebbd1e7b964b6c81a49c7d4c2476584c6279e06
elasticsearch
Recovery Settings: Change settings (still support- old settings) and allow for more dynamic settings
p
https://github.com/elastic/elasticsearch
diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java index d37670caf1332..0dad125120bcf 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/indices/status/TransportIndicesStatusAction.java @@ -39,10 +39,10 @@ import org.elasticsearch.index.gateway.SnapshotStatus; import org.elasticsearch.index.service.InternalIndexService; import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.recovery.RecoveryStatus; -import org.elasticsearch.index.shard.recovery.RecoveryTarget; import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.indices.IndicesService; +import org.elasticsearch.indices.recovery.RecoveryStatus; +import org.elasticsearch.indices.recovery.RecoveryTarget; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/RateLimiter.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/RateLimiter.java new file mode 100644 index 0000000000000..64b2d31421d93 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/RateLimiter.java @@ -0,0 +1,82 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common; + +import org.elasticsearch.ElasticSearchInterruptedException; + +/** + */ +// LUCENE MONITOR: Taken from trunk of Lucene at 06-09-11 +public class RateLimiter { + + private volatile double nsPerByte; + private volatile long lastNS; + + // TODO: we could also allow eg a sub class to dynamically + // determine the allowed rate, eg if an app wants to + // change the allowed rate over time or something + + /** + * mbPerSec is the MB/sec max IO rate + */ + public RateLimiter(double mbPerSec) { + setMaxRate(mbPerSec); + } + + public void setMaxRate(double mbPerSec) { + nsPerByte = 1000000000. / (1024 * 1024 * mbPerSec); + } + + /** + * Pauses, if necessary, to keep the instantaneous IO + * rate at or below the target. NOTE: multiple threads + * may safely use this, however the implementation is + * not perfectly thread safe but likely in practice this + * is harmless (just means in some rare cases the rate + * might exceed the target). It's best to call this + * with a biggish count, not one byte at a time. + */ + public void pause(long bytes) { + + // TODO: this is purely instantenous rate; maybe we + // should also offer decayed recent history one? + final long targetNS = lastNS = lastNS + ((long) (bytes * nsPerByte)); + long curNS = System.nanoTime(); + if (lastNS < curNS) { + lastNS = curNS; + } + + // While loop because Thread.sleep doesn't alway sleep + // enough: + while (true) { + final long pauseNS = targetNS - curNS; + if (pauseNS > 0) { + try { + Thread.sleep((int) (pauseNS / 1000000), (int) (pauseNS % 1000000)); + } catch (InterruptedException ie) { + throw new ElasticSearchInterruptedException("interrupted while rate limiting", ie); + } + curNS = System.nanoTime(); + continue; + } + break; + } + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java index d0e5de295372f..0ead6d7276ac4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java @@ -65,12 +65,12 @@ import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.settings.IndexSettingsService; import org.elasticsearch.index.shard.*; -import org.elasticsearch.index.shard.recovery.RecoveryStatus; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.StoreStats; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.indices.IndicesLifecycle; import org.elasticsearch.indices.InternalIndicesLifecycle; +import org.elasticsearch.indices.recovery.RecoveryStatus; import org.elasticsearch.threadpool.ThreadPool; import java.io.IOException; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesModule.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesModule.java index 567001710b237..8f55b4395dc69 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesModule.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/IndicesModule.java @@ -24,13 +24,14 @@ import org.elasticsearch.common.inject.Module; import org.elasticsearch.common.inject.SpawnModules; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.shard.recovery.RecoverySource; -import org.elasticsearch.index.shard.recovery.RecoveryTarget; import org.elasticsearch.indices.analysis.IndicesAnalysisModule; import org.elasticsearch.indices.cache.filter.IndicesNodeFilterCache; import org.elasticsearch.indices.cluster.IndicesClusterStateService; import org.elasticsearch.indices.memory.IndexingMemoryBufferController; import org.elasticsearch.indices.query.IndicesQueriesModule; +import org.elasticsearch.indices.recovery.RecoverySettings; +import org.elasticsearch.indices.recovery.RecoverySource; +import org.elasticsearch.indices.recovery.RecoveryTarget; import org.elasticsearch.indices.store.TransportNodesListShardStoreMetaData; /** @@ -53,6 +54,7 @@ public IndicesModule(Settings settings) { bind(IndicesService.class).to(InternalIndicesService.class).asEagerSingleton(); + bind(RecoverySettings.class).asEagerSingleton(); bind(RecoveryTarget.class).asEagerSingleton(); bind(RecoverySource.class).asEagerSingleton(); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java index a98f130f0c31e..1ac25b53553e5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/InternalIndicesService.java @@ -75,6 +75,7 @@ import org.elasticsearch.index.store.IndexStoreModule; import org.elasticsearch.index.store.StoreStats; import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.recovery.RecoverySettings; import org.elasticsearch.indices.store.IndicesStore; import org.elasticsearch.plugins.IndexPluginsModule; import org.elasticsearch.plugins.PluginsService; @@ -168,6 +169,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe } @Override protected void doClose() throws ElasticSearchException { + injector.getInstance(RecoverySettings.class).close(); indicesStore.close(); indicesAnalysisService.close(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index 967d0420adb54..0d350ad23c565 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -61,13 +61,12 @@ import org.elasticsearch.index.settings.IndexSettingsService; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.recovery.RecoveryFailedException; -import org.elasticsearch.index.shard.recovery.RecoverySource; -import org.elasticsearch.index.shard.recovery.RecoveryTarget; -import org.elasticsearch.index.shard.recovery.StartRecoveryRequest; import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.indices.IndicesService; +import org.elasticsearch.indices.recovery.RecoveryFailedException; +import org.elasticsearch.indices.recovery.RecoveryTarget; +import org.elasticsearch.indices.recovery.StartRecoveryRequest; import org.elasticsearch.threadpool.ThreadPool; import java.util.List; @@ -88,8 +87,6 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic private final ThreadPool threadPool; - private final RecoverySource recoverySource; - private final RecoveryTarget recoveryTarget; private final ShardStateAction shardStateAction; @@ -113,7 +110,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic private final FailedEngineHandler failedEngineHandler = new FailedEngineHandler(); @Inject public IndicesClusterStateService(Settings settings, IndicesService indicesService, ClusterService clusterService, - ThreadPool threadPool, RecoveryTarget recoveryTarget, RecoverySource recoverySource, + ThreadPool threadPool, RecoveryTarget recoveryTarget, ShardStateAction shardStateAction, NodeIndexCreatedAction nodeIndexCreatedAction, NodeIndexDeletedAction nodeIndexDeletedAction, NodeMappingCreatedAction nodeMappingCreatedAction, NodeMappingRefreshAction nodeMappingRefreshAction, @@ -122,7 +119,6 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic this.indicesService = indicesService; this.clusterService = clusterService; this.threadPool = threadPool; - this.recoverySource = recoverySource; this.recoveryTarget = recoveryTarget; this.shardStateAction = shardStateAction; this.nodeIndexCreatedAction = nodeIndexCreatedAction; @@ -141,7 +137,6 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic } @Override protected void doClose() throws ElasticSearchException { - recoverySource.close(); } @Override public void clusterChanged(final ClusterChangedEvent event) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/IgnoreRecoveryException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java similarity index 96% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/IgnoreRecoveryException.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java index e1185189127f9..08c28d2f1b7da 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/IgnoreRecoveryException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/IgnoreRecoveryException.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.ElasticSearchException; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverFilesRecoveryException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java similarity index 97% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverFilesRecoveryException.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java index e085befed244b..3e12af62b91d1 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverFilesRecoveryException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverFilesRecoveryException.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.ElasticSearchWrapperException; import org.elasticsearch.common.unit.ByteSizeValue; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryCleanFilesRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java similarity index 97% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryCleanFilesRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java index 185381279a1cd..b42df9a941a62 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryCleanFilesRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryCleanFilesRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.collect.Sets; import org.elasticsearch.common.io.stream.StreamInput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFailedException.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java similarity index 96% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFailedException.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java index f823046b5189e..08ed81b70d143 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFailedException.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFailedException.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.cluster.node.DiscoveryNode; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFileChunkRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFileChunkRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java index 4a04ffc79304b..24f2292fd7d54 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFileChunkRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFileChunkRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFilesInfoRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFilesInfoRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java index ff899e04c9c73..7683172e51eaa 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFilesInfoRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFinalizeRecoveryRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java similarity index 97% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFinalizeRecoveryRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java index 67ec3c2117987..029403e8dfba8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryFinalizeRecoveryRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryFinalizeRecoveryRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryPrepareForTranslogOperationsRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java similarity index 97% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryPrepareForTranslogOperationsRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java index c784ee2bc259d..65bc7113438e8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryPrepareForTranslogOperationsRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryPrepareForTranslogOperationsRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryResponse.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryResponse.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java index cfecc67527615..738b5052a99db 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryResponse.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryResponse.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java new file mode 100644 index 0000000000000..121f7a894b0de --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySettings.java @@ -0,0 +1,135 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.indices.recovery; + +import org.elasticsearch.cluster.metadata.MetaData; +import org.elasticsearch.common.component.AbstractComponent; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.unit.ByteSizeUnit; +import org.elasticsearch.common.unit.ByteSizeValue; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.common.util.concurrent.DynamicExecutors; +import org.elasticsearch.common.util.concurrent.EsExecutors; +import org.elasticsearch.node.settings.NodeSettingsService; + +import java.util.concurrent.ThreadPoolExecutor; + +/** + */ +public class RecoverySettings extends AbstractComponent { + + static { + MetaData.addDynamicSettings("indices.recovery.file_chunk_size"); + MetaData.addDynamicSettings("indices.recovery.translog_ops"); + MetaData.addDynamicSettings("indices.recovery.translog_size"); + MetaData.addDynamicSettings("indices.recovery.compress"); + MetaData.addDynamicSettings("`"); + } + + private volatile ByteSizeValue fileChunkSize; + + private volatile boolean compress; + private volatile int translogOps; + private volatile ByteSizeValue translogSize; + + private volatile int concurrentStreams; + private final ThreadPoolExecutor concurrentStreamPool; + + @Inject public RecoverySettings(Settings settings, NodeSettingsService nodeSettingsService) { + super(settings); + + this.fileChunkSize = componentSettings.getAsBytesSize("file_chunk_size", settings.getAsBytesSize("index.shard.recovery.file_chunk_size", new ByteSizeValue(100, ByteSizeUnit.KB))); + this.translogOps = componentSettings.getAsInt("translog_ops", settings.getAsInt("index.shard.recovery.translog_ops", 1000)); + this.translogSize = componentSettings.getAsBytesSize("translog_size", settings.getAsBytesSize("index.shard.recovery.translog_size", new ByteSizeValue(100, ByteSizeUnit.KB))); + this.compress = componentSettings.getAsBoolean("compress", true); + + this.concurrentStreams = componentSettings.getAsInt("concurrent_streams", settings.getAsInt("index.shard.recovery.concurrent_streams", 5)); + this.concurrentStreamPool = (ThreadPoolExecutor) DynamicExecutors.newScalingThreadPool(1, concurrentStreams, TimeValue.timeValueSeconds(5).millis(), EsExecutors.daemonThreadFactory(settings, "[recovery_stream]")); + + logger.debug("using concurrent_streams [{}], file_chunk_size [{}], translog_size [{}], translog_ops [{}], and compress [{}]", + concurrentStreams, fileChunkSize, translogSize, translogOps, compress); + + nodeSettingsService.addListener(new ApplySettings()); + } + + public void close() { + concurrentStreamPool.shutdown(); + } + + public ByteSizeValue fileChunkSize() { + return fileChunkSize; + } + + public boolean compress() { + return compress; + } + + public int translogOps() { + return translogOps; + } + + public ByteSizeValue translogSize() { + return translogSize; + } + + public int concurrentStreams() { + return concurrentStreams; + } + + public ThreadPoolExecutor concurrentStreamPool() { + return concurrentStreamPool; + } + + class ApplySettings implements NodeSettingsService.Listener { + @Override public void onRefreshSettings(Settings settings) { + ByteSizeValue fileChunkSize = settings.getAsBytesSize("indices.recovery.file_chunk_size", RecoverySettings.this.fileChunkSize); + if (!fileChunkSize.equals(RecoverySettings.this.fileChunkSize)) { + logger.info("updating [indices.recovery.file_chunk_size] from [{}] to [{}]", RecoverySettings.this.fileChunkSize, fileChunkSize); + RecoverySettings.this.fileChunkSize = fileChunkSize; + } + + int translogOps = settings.getAsInt("indices.recovery.translog_ops", RecoverySettings.this.translogOps); + if (translogOps != RecoverySettings.this.translogOps) { + logger.info("updating [indices.recovery.translog_ops] from [{}] to [{}]", RecoverySettings.this.translogOps, translogOps); + RecoverySettings.this.translogOps = translogOps; + } + + ByteSizeValue translogSize = settings.getAsBytesSize("indices.recovery.translog_size", RecoverySettings.this.translogSize); + if (!translogSize.equals(RecoverySettings.this.translogSize)) { + logger.info("updating [indices.recovery.translog_size] from [{}] to [{}]", RecoverySettings.this.translogSize, translogSize); + RecoverySettings.this.translogSize = translogSize; + } + + boolean compress = settings.getAsBoolean("indices.recovery.compress", RecoverySettings.this.compress); + if (compress != RecoverySettings.this.compress) { + logger.info("updating [indices.recovery.compress] from [{}] to [{}]", RecoverySettings.this.compress, compress); + RecoverySettings.this.compress = compress; + } + + int concurrentStreams = settings.getAsInt("indices.recovery.concurrent_streams", RecoverySettings.this.concurrentStreams); + if (concurrentStreams != RecoverySettings.this.concurrentStreams) { + logger.info("updating [indices.recovery.concurrent_streams] from [{}] to [{}]", RecoverySettings.this.concurrentStreams, concurrentStreams); + RecoverySettings.this.concurrentStreams = concurrentStreams; + RecoverySettings.this.concurrentStreamPool.setMaximumPoolSize(concurrentStreams); + } + } + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java similarity index 83% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java index 55370faf84cff..c3d912428b2f8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoverySource.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoverySource.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.apache.lucene.store.IndexInput; import org.elasticsearch.ElasticSearchException; @@ -28,11 +28,7 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; -import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.common.util.concurrent.DynamicExecutors; -import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.shard.IllegalIndexShardStateException; @@ -42,7 +38,6 @@ import org.elasticsearch.index.store.StoreFileMetaData; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.indices.IndicesService; -import org.elasticsearch.node.settings.NodeSettingsService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.BaseTransportRequestHandler; import org.elasticsearch.transport.TransportChannel; @@ -54,14 +49,11 @@ import java.util.List; import java.util.Set; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.atomic.AtomicReference; /** * The source recovery accepts recovery requests from other peer shards and start the recovery process from this * source shard to the target shard. - * - * @author kimchy (shay.banon) */ public class RecoverySource extends AbstractComponent { @@ -79,42 +71,19 @@ public static class Actions { private final IndicesService indicesService; + private final RecoverySettings recoverySettings; - private final ByteSizeValue fileChunkSize; - - private final boolean compress; - - private final int translogOps; - private final ByteSizeValue translogSize; - - private volatile int concurrentStreams; - private final ThreadPoolExecutor concurrentStreamPool; @Inject public RecoverySource(Settings settings, ThreadPool threadPool, TransportService transportService, IndicesService indicesService, - NodeSettingsService nodeSettingsService) { + RecoverySettings recoverySettings) { super(settings); this.threadPool = threadPool; this.transportService = transportService; this.indicesService = indicesService; - this.concurrentStreams = componentSettings.getAsInt("concurrent_streams", 5); - this.concurrentStreamPool = (ThreadPoolExecutor) DynamicExecutors.newScalingThreadPool(1, concurrentStreams, TimeValue.timeValueSeconds(5).millis(), EsExecutors.daemonThreadFactory(settings, "[recovery_stream]")); - - this.fileChunkSize = componentSettings.getAsBytesSize("file_chunk_size", new ByteSizeValue(100, ByteSizeUnit.KB)); - this.translogOps = componentSettings.getAsInt("translog_ops", 1000); - this.translogSize = componentSettings.getAsBytesSize("translog_size", new ByteSizeValue(100, ByteSizeUnit.KB)); - this.compress = componentSettings.getAsBoolean("compress", true); - - logger.debug("using concurrent_streams [{}], file_chunk_size [{}], translog_size [{}], translog_ops [{}], and compress [{}]", - concurrentStreams, fileChunkSize, translogSize, translogOps, compress); + this.recoverySettings = recoverySettings; transportService.registerHandler(Actions.START_RECOVERY, new StartRecoveryTransportRequestHandler()); - - nodeSettingsService.addListener(new ApplySettings()); - } - - public void close() { - concurrentStreamPool.shutdown(); } private RecoveryResponse recover(final StartRecoveryRequest request) { @@ -166,11 +135,11 @@ private RecoveryResponse recover(final StartRecoveryRequest request) { final CountDownLatch latch = new CountDownLatch(response.phase1FileNames.size()); final AtomicReference<Exception> lastException = new AtomicReference<Exception>(); for (final String name : response.phase1FileNames) { - concurrentStreamPool.execute(new Runnable() { + recoverySettings.concurrentStreamPool().execute(new Runnable() { @Override public void run() { IndexInput indexInput = null; try { - final int BUFFER_SIZE = (int) fileChunkSize.bytes(); + final int BUFFER_SIZE = (int) recoverySettings.fileChunkSize().bytes(); byte[] buf = new byte[BUFFER_SIZE]; StoreFileMetaData md = shard.store().metaData(name); indexInput = snapshot.getDirectory().openInput(name); @@ -184,7 +153,7 @@ private RecoveryResponse recover(final StartRecoveryRequest request) { long position = indexInput.getFilePointer(); indexInput.readBytes(buf, 0, toRead, false); transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.FILE_CHUNK, new RecoveryFileChunkRequest(request.shardId(), name, position, len, md.checksum(), buf, toRead), - TransportRequestOptions.options().withCompress(compress).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); + TransportRequestOptions.options().withCompress(recoverySettings.compress()).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); readCount += toRead; } indexInput.close(); @@ -277,9 +246,9 @@ private int sendSnapshot(Translog.Snapshot snapshot) throws ElasticSearchExcepti ops += 1; size += operation.estimateSize(); totalOperations++; - if (ops >= translogOps || size >= translogSize.bytes()) { + if (ops >= recoverySettings.translogOps() || size >= recoverySettings.translogSize().bytes()) { RecoveryTranslogOperationsRequest translogOperationsRequest = new RecoveryTranslogOperationsRequest(request.shardId(), operations); - transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.TRANSLOG_OPS, translogOperationsRequest, TransportRequestOptions.options().withCompress(compress).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); + transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.TRANSLOG_OPS, translogOperationsRequest, TransportRequestOptions.options().withCompress(recoverySettings.compress()).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); ops = 0; size = 0; operations.clear(); @@ -288,7 +257,7 @@ private int sendSnapshot(Translog.Snapshot snapshot) throws ElasticSearchExcepti // send the leftover if (!operations.isEmpty()) { RecoveryTranslogOperationsRequest translogOperationsRequest = new RecoveryTranslogOperationsRequest(request.shardId(), operations); - transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.TRANSLOG_OPS, translogOperationsRequest, TransportRequestOptions.options().withCompress(compress).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); + transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.TRANSLOG_OPS, translogOperationsRequest, TransportRequestOptions.options().withCompress(recoverySettings.compress()).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet(); } return totalOperations; } @@ -311,16 +280,5 @@ class StartRecoveryTransportRequestHandler extends BaseTransportRequestHandler<S channel.sendResponse(response); } } - - class ApplySettings implements NodeSettingsService.Listener { - @Override public void onRefreshSettings(Settings settings) { - int concurrentStreams = settings.getAsInt("index.shard.recovery.concurrent_streams", RecoverySource.this.concurrentStreams); - if (concurrentStreams != RecoverySource.this.concurrentStreams) { - logger.info("updating [index.shard.recovery.concurrent_streams] from [{}] to [{}]", RecoverySource.this.concurrentStreams, concurrentStreams); - RecoverySource.this.concurrentStreams = concurrentStreams; - RecoverySource.this.concurrentStreamPool.setMaximumPoolSize(concurrentStreams); - } - } - } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryStatus.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryStatus.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java index c20c2f01c3bc2..bc43f54ba5683 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryStatus.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryStatus.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.apache.lucene.store.IndexOutput; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java similarity index 99% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java index 0385fe9d9969b..428cc7e358448 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTarget.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.IndexOutput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTranslogOperationsRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTranslogOperationsRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java index cbcb1830fd657..7db2df0c4dd1e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/RecoveryTranslogOperationsRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/RecoveryTranslogOperationsRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.io.stream.StreamInput; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/StartRecoveryRequest.java b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java similarity index 98% rename from modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/StartRecoveryRequest.java rename to modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java index c413eacbcf2c6..bddbd0d803cf4 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/recovery/StartRecoveryRequest.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.recovery; +package org.elasticsearch.indices.recovery; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.collect.Maps;
8e0167a91d4717daead6e14541c7655ee45c1430
tapiji
updated licenses
p
https://github.com/tapiji/tapiji
diff --git a/at.ac.tuwien.inso.eclipse.i18n.jsf/epl-v10.html b/at.ac.tuwien.inso.eclipse.i18n.jsf/epl-v10.html new file mode 100644 index 00000000..ed4b1966 --- /dev/null +++ b/at.ac.tuwien.inso.eclipse.i18n.jsf/epl-v10.html @@ -0,0 +1,328 @@ +<html xmlns:o="urn:schemas-microsoft-com:office:office" +xmlns:w="urn:schemas-microsoft-com:office:word" +xmlns="http://www.w3.org/TR/REC-html40"> + +<head> +<meta http-equiv=Content-Type content="text/html; charset=windows-1252"> +<meta name=ProgId content=Word.Document> +<meta name=Generator content="Microsoft Word 9"> +<meta name=Originator content="Microsoft Word 9"> +<link rel=File-List +href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"> +<title>Eclipse Public License - Version 1.0</title> +<!--[if gte mso 9]><xml> + <o:DocumentProperties> + <o:Revision>2</o:Revision> + <o:TotalTime>3</o:TotalTime> + <o:Created>2004-03-05T23:03:00Z</o:Created> + <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> + <o:Pages>4</o:Pages> + <o:Words>1626</o:Words> + <o:Characters>9270</o:Characters> + <o:Lines>77</o:Lines> + <o:Paragraphs>18</o:Paragraphs> + <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> + <o:Version>9.4402</o:Version> + </o:DocumentProperties> +</xml><![endif]--><!--[if gte mso 9]><xml> + <w:WordDocument> + <w:TrackRevisions/> + </w:WordDocument> +</xml><![endif]--> +<style> +<!-- + /* Font Definitions */ +@font-face + {font-family:Tahoma; + panose-1:2 11 6 4 3 5 4 4 2 4; + mso-font-charset:0; + mso-generic-font-family:swiss; + mso-font-pitch:variable; + mso-font-signature:553679495 -2147483648 8 0 66047 0;} + /* Style Definitions */ +p.MsoNormal, li.MsoNormal, div.MsoNormal + {mso-style-parent:""; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p + {margin-right:0in; + mso-margin-top-alt:auto; + mso-margin-bottom-alt:auto; + margin-left:0in; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p.BalloonText, li.BalloonText, div.BalloonText + {mso-style-name:"Balloon Text"; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:8.0pt; + font-family:Tahoma; + mso-fareast-font-family:"Times New Roman";} +@page Section1 + {size:8.5in 11.0in; + margin:1.0in 1.25in 1.0in 1.25in; + mso-header-margin:.5in; + mso-footer-margin:.5in; + mso-paper-source:0;} +div.Section1 + {page:Section1;} +--> +</style> +</head> + +<body lang=EN-US style='tab-interval:.5in'> + +<div class=Section1> + +<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b> +</p> + +<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.</span> </p> + +<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p> + +<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and<br clear=left> +b) in the case of each subsequent Contributor:</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i) +changes to the Program, and</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii) +additions to the Program;</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program. </span></p> + +<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or +entity that distributes the Program.</span> </p> + +<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program. </span></p> + +<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions +distributed in accordance with this Agreement.</span> </p> + +<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who +receives the Program under this Agreement, including all Contributors.</span> </p> + +<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to<span +style='color:red'> </span>reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder. </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. </span></p> + +<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p> + +<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that:</span> +</p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +it complies with the terms and conditions of this Agreement; and</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) +its license agreement:</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits; </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.<span style='color:blue'> </span></span></p> + +<p><span style='font-size:10.0pt'>When the Program is made available in source +code form:</span> </p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +it must be made available under this Agreement; and </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a +copy of this Agreement must be included with each copy of the Program. </span></p> + +<p><span style='font-size:10.0pt'>Contributors may not remove or alter any +copyright notices contained within the Program. </span></p> + +<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. </span></p> + +<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p> + +<p><span style='font-size:10.0pt'>Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor (&quot;Commercial +Contributor&quot;) hereby agrees to defend and indemnify every other +Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and +costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.</span> </p> + +<p><span style='font-size:10.0pt'>For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.</span> </p> + +<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p> + +<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. </span></p> + +<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p> + +<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.</span> </p> + +<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p> + +<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.</span> </p> + +<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed. </span></p> + +<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive. </span></p> + +<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.</span> </p> + +<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.</span> </p> + +<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p> + +</div> + +</body> + +</html> \ No newline at end of file
77048935bbd5ab61f9c3a7e05172c4f8e7fee326
Vala
sqlite3: add binding for sqlite3_update_hook
a
https://github.com/GNOME/vala/
diff --git a/vapi/sqlite3.vapi b/vapi/sqlite3.vapi index 4ae8cd31d1..d44db089dc 100644 --- a/vapi/sqlite3.vapi +++ b/vapi/sqlite3.vapi @@ -85,6 +85,7 @@ namespace Sqlite { public void progress_handler (int n_opcodes, Sqlite.ProgressCallback? progress_handler); public void commit_hook (CommitCallback? commit_hook); public void rollback_hook (RollbackCallback? rollback_hook); + public void update_hook (UpdateCallback? update_hook); public int create_function (string zFunctionName, int nArg, int eTextRep, void * user_data, UserFuncCallback? xFunc, UserFuncCallback? xStep, UserFuncFinishCallback? xFinal); } @@ -101,6 +102,8 @@ namespace Sqlite { public delegate void UserFuncCallback (Sqlite.Context context, [CCode (array_length_pos = 1.1)] Sqlite.Value[] values); [CCode (has_target = false)] public delegate void UserFuncFinishCallback (Sqlite.Context context); + [CCode (instance_pos = 0)] + public delegate void UpdateCallback (Sqlite.Action action, string dbname, string table, int64 rowid); public unowned string? compileoption_get (int n); public int compileoption_used (string option_name);
4cb637b9768b3ba1bcfc55d317ca26401f7b9a95
Vala
gio-2.0: set default value of g_zlib_compressor_new.level to -1
a
https://github.com/GNOME/vala/
diff --git a/vapi/gio-2.0.vapi b/vapi/gio-2.0.vapi index 96863f5e7d..bcf450c55f 100644 --- a/vapi/gio-2.0.vapi +++ b/vapi/gio-2.0.vapi @@ -938,7 +938,7 @@ namespace GLib { [CCode (cheader_filename = "gio/gio.h")] public class ZlibCompressor : GLib.Object, GLib.Converter { [CCode (has_construct_function = false)] - public ZlibCompressor (GLib.ZlibCompressorFormat format, int level); + public ZlibCompressor (GLib.ZlibCompressorFormat format, int level = -1); [NoAccessorMethod] public GLib.ZlibCompressorFormat format { get; construct; } [NoAccessorMethod] diff --git a/vapi/packages/gio-2.0/gio-2.0.metadata b/vapi/packages/gio-2.0/gio-2.0.metadata index 776275a591..feb178db58 100644 --- a/vapi/packages/gio-2.0/gio-2.0.metadata +++ b/vapi/packages/gio-2.0/gio-2.0.metadata @@ -180,3 +180,5 @@ g_volume_monitor_get_mount_for_uuid transfer_ownership="1" g_volume_monitor_get_mounts type_arguments="Mount" transfer_ownership="1" g_volume_monitor_get_volume_for_uuid transfer_ownership="1" g_volume_monitor_get_volumes type_arguments="Volume" transfer_ownership="1" + +g_zlib_compressor_new.level default_value="-1"
53c2131d4411fac6fbe43fc757bc6acea780e2a1
crashub$crash
Add flexibility for plugin a custom class manager
p
https://github.com/crashub/crash
diff --git a/shell/core/src/main/java/org/crsh/shell/impl/command/AbstractClassManager.java b/shell/core/src/main/java/org/crsh/shell/impl/command/AbstractClassManager.java new file mode 100644 index 000000000..f9a8180ba --- /dev/null +++ b/shell/core/src/main/java/org/crsh/shell/impl/command/AbstractClassManager.java @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2012 eXo Platform SAS. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.crsh.shell.impl.command; + +import groovy.lang.GroovyClassLoader; +import groovy.lang.GroovyCodeSource; +import groovy.lang.Script; +import org.codehaus.groovy.control.CompilationFailedException; +import org.codehaus.groovy.control.CompilerConfiguration; +import org.crsh.command.CommandInvoker; +import org.crsh.command.NoSuchCommandException; +import org.crsh.plugin.PluginContext; +import org.crsh.shell.ErrorType; +import org.crsh.util.TimestampedObject; +import org.crsh.vfs.Resource; + +import java.io.UnsupportedEncodingException; + +public abstract class AbstractClassManager<T> { + + /** . */ + private final PluginContext context; + + /** . */ + private final CompilerConfiguration config; + + /** . */ + private final Class<T> baseClass; + + protected AbstractClassManager(PluginContext context, Class<T> baseClass, Class<? extends Script> baseScriptClass) { + CompilerConfiguration config = new CompilerConfiguration(); + config.setRecompileGroovySource(true); + config.setScriptBaseClass(baseScriptClass.getName()); + + // + this.context = context; + this.config = config; + this.baseClass = baseClass; + } + + protected abstract TimestampedObject<Class<? extends T>> loadClass(String name); + + protected abstract void saveClass(String name, TimestampedObject<Class<? extends T>> clazz); + + protected abstract Resource getResource(String name); + + Class<? extends T> getClass(String name) throws NoSuchCommandException, NullPointerException { + if (name == null) { + throw new NullPointerException("No null argument allowed"); + } + + TimestampedObject<Class<? extends T>> providerRef = loadClass(name); + + // + Resource script = getResource(name); + + // + if (script != null) { + if (providerRef != null) { + if (script.getTimestamp() != providerRef.getTimestamp()) { + providerRef = null; + } + } + + // + if (providerRef == null) { + + // + String source; + try { + source = new String(script.getContent(), "UTF-8"); + } + catch (UnsupportedEncodingException e) { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); + } + + // + Class<?> clazz; + try { + GroovyCodeSource gcs = new GroovyCodeSource(source, name, "/groovy/shell"); + GroovyClassLoader gcl = new GroovyClassLoader(context.getLoader(), config); + clazz = gcl.parseClass(gcs, false); + } + catch (NoClassDefFoundError e) { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); + } + catch (CompilationFailedException e) { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); + } + + // + if (baseClass.isAssignableFrom(clazz)) { + Class<? extends T> providerClass = clazz.asSubclass(baseClass); + providerRef = new TimestampedObject<Class<? extends T>>(script.getTimestamp(), providerClass); + saveClass(name, providerRef); + } else { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Parsed script " + clazz.getName() + + " does not implements " + CommandInvoker.class.getName()); + } + } + } + + // + if (providerRef == null) { + return null; + } + + // + return providerRef.getObject(); + } + + T getInstance(String name) throws NoSuchCommandException, NullPointerException { + Class<? extends T> clazz = getClass(name); + if (clazz == null) { + return null; + } + + // + try { + return clazz.newInstance(); + } + catch (Exception e) { + throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not create command " + name + " instance", e); + } + } +} diff --git a/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java b/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java index ce0d38949..35c96e519 100644 --- a/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java +++ b/shell/core/src/main/java/org/crsh/shell/impl/command/CRaSH.java @@ -19,7 +19,6 @@ package org.crsh.shell.impl.command; -import groovy.lang.Script; import org.crsh.command.GroovyScript; import org.crsh.command.GroovyScriptCommand; import org.crsh.command.NoSuchCommandException; @@ -33,10 +32,10 @@ public class CRaSH { /** . */ - final ClassManager<? extends ShellCommand> commandManager; + final AbstractClassManager<? extends ShellCommand> commandManager; /** . */ - final ClassManager<? extends GroovyScript> scriptManager; + final AbstractClassManager<? extends GroovyScript> scriptManager; /** . */ final PluginContext context; @@ -55,7 +54,7 @@ public CRaSH(PluginContext context) throws NullPointerException { ); } - public CRaSH(PluginContext context, ClassManager<ShellCommand> commandManager, ClassManager<? extends GroovyScript> scriptManager) { + public CRaSH(PluginContext context, AbstractClassManager<ShellCommand> commandManager, AbstractClassManager<? extends GroovyScript> scriptManager) { this.context = context; this.commandManager = commandManager; this.scriptManager = scriptManager; diff --git a/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java b/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java index 1369cee1d..ddf3cfaea 100644 --- a/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java +++ b/shell/core/src/main/java/org/crsh/shell/impl/command/ClassManager.java @@ -19,25 +19,16 @@ package org.crsh.shell.impl.command; -import groovy.lang.GroovyClassLoader; -import groovy.lang.GroovyCodeSource; import groovy.lang.Script; -import org.codehaus.groovy.control.CompilationFailedException; -import org.codehaus.groovy.control.CompilerConfiguration; -import org.crsh.command.CommandInvoker; -import org.crsh.command.GroovyScriptCommand; -import org.crsh.command.NoSuchCommandException; import org.crsh.plugin.PluginContext; import org.crsh.plugin.ResourceKind; -import org.crsh.shell.ErrorType; import org.crsh.util.TimestampedObject; import org.crsh.vfs.Resource; -import java.io.UnsupportedEncodingException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -class ClassManager<T> { +public class ClassManager<T> extends AbstractClassManager<T> { /** . */ private final Map<String, TimestampedObject<Class<? extends T>>> classes = new ConcurrentHashMap<String, TimestampedObject<Class<? extends T>>>(); @@ -45,104 +36,29 @@ class ClassManager<T> { /** . */ private final PluginContext context; - /** . */ - private final CompilerConfiguration config; - - /** . */ - private final Class<T> baseClass; - /** . */ private final ResourceKind kind; - ClassManager(PluginContext context, ResourceKind kind, Class<T> baseClass, Class<? extends Script> baseScriptClass) { - CompilerConfiguration config = new CompilerConfiguration(); - config.setRecompileGroovySource(true); - config.setScriptBaseClass(baseScriptClass.getName()); + public ClassManager(PluginContext context, ResourceKind kind, Class<T> baseClass, Class<? extends Script> baseScriptClass) { + super(context, baseClass, baseScriptClass); // this.context = context; - this.config = config; - this.baseClass = baseClass; this.kind = kind; } - Class<? extends T> getClass(String name) throws NoSuchCommandException, NullPointerException { - if (name == null) { - throw new NullPointerException("No null argument allowed"); - } - - TimestampedObject<Class<? extends T>> providerRef = classes.get(name); - - // - Resource script = context.loadResource(name, kind); - - // - if (script != null) { - if (providerRef != null) { - if (script.getTimestamp() != providerRef.getTimestamp()) { - providerRef = null; - } - } - - // - if (providerRef == null) { - - // - String source; - try { - source = new String(script.getContent(), "UTF-8"); - } - catch (UnsupportedEncodingException e) { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); - } - - // - Class<?> clazz; - try { - GroovyCodeSource gcs = new GroovyCodeSource(source, name, "/groovy/shell"); - GroovyClassLoader gcl = new GroovyClassLoader(context.getLoader(), config); - clazz = gcl.parseClass(gcs, false); - } - catch (NoClassDefFoundError e) { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); - } - catch (CompilationFailedException e) { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not compile command script " + name, e); - } - - // - if (baseClass.isAssignableFrom(clazz)) { - Class<? extends T> providerClass = clazz.asSubclass(baseClass); - providerRef = new TimestampedObject<Class<? extends T>>(script.getTimestamp(), providerClass); - classes.put(name, providerRef); - } else { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Parsed script " + clazz.getName() + - " does not implements " + CommandInvoker.class.getName()); - } - } - } - - // - if (providerRef == null) { - return null; - } - - // - return providerRef.getObject(); + @Override + protected TimestampedObject<Class<? extends T>> loadClass(String name) { + return classes.get(name); } - T getInstance(String name) throws NoSuchCommandException, NullPointerException { - Class<? extends T> clazz = getClass(name); - if (clazz == null) { - return null; - } + @Override + protected void saveClass(String name, TimestampedObject<Class<? extends T>> clazz) { + classes.put(name, clazz); + } - // - try { - return clazz.newInstance(); - } - catch (Exception e) { - throw new NoSuchCommandException(name, ErrorType.INTERNAL, "Could not create command " + name + " instance", e); - } + @Override + protected Resource getResource(String name) { + return context.loadResource(name, kind); } }
0338b71df28dc82f5bbb6aa777f51809549dffeb
Delta Spike
DELTASPIKE-241 new weld-arquillian container fixes BDA issues
p
https://github.com/apache/deltaspike
diff --git a/deltaspike/parent/pom.xml b/deltaspike/parent/pom.xml index 18c625680..2410e7799 100644 --- a/deltaspike/parent/pom.xml +++ b/deltaspike/parent/pom.xml @@ -89,7 +89,7 @@ <jacoco.version>0.5.7.201204190339</jacoco.version> <arquillian-openwebbeans.version>1.0.0.CR2</arquillian-openwebbeans.version> - <arquillian-weld.version>1.0.0.CR4</arquillian-weld.version> + <arquillian-weld.version>1.0.0.CR5</arquillian-weld.version> <!-- OSGi bundles properties --> <deltaspike.osgi.import.deltaspike.version>version="[$(version;==;${deltaspike.osgi.version.clean}),$(version;=+;${deltaspike.osgi.version.clean}))"</deltaspike.osgi.import.deltaspike.version>
caeeaaa03f71fffaba3a03409b724e4cd9fc03e2
apache$hama
HAMA-783: Efficient InMemory Storage for Vertices git-svn-id: https://svn.apache.org/repos/asf/hama/trunk@1555020 13f79535-47bb-0310-9956-ffa450edef68
p
https://github.com/apache/hama
diff --git a/examples/src/main/java/org/apache/hama/examples/SSSP.java b/examples/src/main/java/org/apache/hama/examples/SSSP.java index ed1777ecc..910b2d750 100644 --- a/examples/src/main/java/org/apache/hama/examples/SSSP.java +++ b/examples/src/main/java/org/apache/hama/examples/SSSP.java @@ -69,7 +69,6 @@ public void compute(Iterable<IntWritable> messages) throws IOException { } voteToHalt(); } - } public static class MinIntCombiner extends Combiner<IntWritable> { diff --git a/graph/src/main/java/org/apache/hama/graph/DiskVerticesInfo.java b/graph/src/main/java/org/apache/hama/graph/DiskVerticesInfo.java index cd5d480b9..946acb3ad 100644 --- a/graph/src/main/java/org/apache/hama/graph/DiskVerticesInfo.java +++ b/graph/src/main/java/org/apache/hama/graph/DiskVerticesInfo.java @@ -17,12 +17,13 @@ */ package org.apache.hama.graph; +import static com.google.common.base.Preconditions.checkArgument; + import java.io.IOException; import java.util.ArrayList; import java.util.BitSet; import java.util.Collections; -import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; @@ -31,11 +32,10 @@ import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; +import org.apache.hama.HamaConfiguration; import org.apache.hama.bsp.TaskAttemptID; import org.apache.hama.graph.IDSkippingIterator.Strategy; -import static com.google.common.base.Preconditions.checkArgument; - @SuppressWarnings("rawtypes") public final class DiskVerticesInfo<V extends WritableComparable, E extends Writable, M extends Writable> implements VerticesInfo<V, E, M> { @@ -67,12 +67,12 @@ public final class DiskVerticesInfo<V extends WritableComparable, E extends Writ private Vertex<V, E, M> cachedVertexInstance; private int currentStep = 0; private int index = 0; - private Configuration conf; + private HamaConfiguration conf; private GraphJobRunner<V, E, M> runner; private String staticFile; @Override - public void init(GraphJobRunner<V, E, M> runner, Configuration conf, + public void init(GraphJobRunner<V, E, M> runner, HamaConfiguration conf, TaskAttemptID attempt) throws IOException { this.runner = runner; this.conf = conf; @@ -92,7 +92,7 @@ public void init(GraphJobRunner<V, E, M> runner, Configuration conf, } @Override - public void cleanup(Configuration conf, TaskAttemptID attempt) + public void cleanup(HamaConfiguration conf, TaskAttemptID attempt) throws IOException { IOUtils.cleanup(null, softGraphPartsDos, softGraphPartsNextIterationDos, staticGraphPartsDis, softGraphPartsDis); @@ -122,7 +122,7 @@ public void addVertex(Vertex<V, E, M> vertex) throws IOException { @Override public void removeVertex(V vertexID) { - throw new UnsupportedOperationException ("Not yet implemented"); + throw new UnsupportedOperationException("Not yet implemented"); } /** @@ -176,7 +176,7 @@ public void finishAdditions() { @Override public void finishRemovals() { - throw new UnsupportedOperationException ("Not yet implemented"); + throw new UnsupportedOperationException("Not yet implemented"); } private static long[] copy(ArrayList<Long> lst) { diff --git a/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java b/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java index 4e2566c80..908675f71 100644 --- a/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java +++ b/graph/src/main/java/org/apache/hama/graph/GraphJobRunner.java @@ -248,12 +248,14 @@ private void doSuperstep(GraphJobMessage currentMessage, int activeVertices = 0; this.changedVertexCnt = 0; vertices.startSuperstep(); + /* * We iterate over our messages and vertices in sorted order. That means * that we need to seek the first vertex that has the same ID as the * currentMessage or the first vertex that is active. */ IDSkippingIterator<V, E, M> iterator = vertices.skippingIterator(); + // note that can't skip inactive vertices because we have to rewrite the // complete vertex file in each iteration while (iterator.hasNext( @@ -266,9 +268,11 @@ private void doSuperstep(GraphJobMessage currentMessage, iterable = iterate(currentMessage, (V) currentMessage.getVertexId(), vertex, peer); } + if (iterable != null && vertex.isHalted()) { vertex.setActive(); } + if (!vertex.isHalted()) { M lastValue = vertex.getValue(); if (iterable == null) { @@ -285,7 +289,7 @@ private void doSuperstep(GraphJobMessage currentMessage, getAggregationRunner().aggregateVertex(lastValue, vertex); activeVertices++; } - + // note that we even need to rewrite the vertex if it is halted for // consistency reasons vertices.finishVertexComputation(vertex); @@ -352,7 +356,10 @@ private void doInitialSuperstep( IDSkippingIterator<V, E, M> skippingIterator = vertices.skippingIterator(); while (skippingIterator.hasNext()) { Vertex<V, E, M> vertex = skippingIterator.next(); + M lastValue = vertex.getValue(); + // Calls setup method. + vertex.setup(conf); vertex.compute(Collections.singleton(vertex.getValue())); getAggregationRunner().aggregateVertex(lastValue, vertex); vertices.finishVertexComputation(vertex); @@ -456,9 +463,6 @@ private void loadVertices( vertex.addEdge(edge); } } else { - vertex.setRunner(this); - vertex.setup(conf); - if (selfReference) { vertex.addEdge(new Edge<V, E>(vertex.getVertexID(), null)); } @@ -469,8 +473,6 @@ private void loadVertices( } } // add last vertex. - vertex.setRunner(this); - vertex.setup(conf); if (selfReference) { vertex.addEdge(new Edge<V, E>(vertex.getVertexID(), null)); } diff --git a/graph/src/main/java/org/apache/hama/graph/IDSkippingIterator.java b/graph/src/main/java/org/apache/hama/graph/IDSkippingIterator.java index 814496e17..02ab6c131 100644 --- a/graph/src/main/java/org/apache/hama/graph/IDSkippingIterator.java +++ b/graph/src/main/java/org/apache/hama/graph/IDSkippingIterator.java @@ -17,6 +17,8 @@ */ package org.apache.hama.graph; +import java.io.IOException; + import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; @@ -54,8 +56,9 @@ public boolean accept(Vertex v, WritableComparable msgId) { * Skips nothing, accepts everything. * * @return true if the strategy found a new item, false if not. + * @throws IOException */ - public boolean hasNext() { + public boolean hasNext() throws IOException { return hasNext(null, Strategy.ALL); } @@ -63,8 +66,9 @@ public boolean hasNext() { * Skips until the given strategy is satisfied. * * @return true if the strategy found a new item, false if not. + * @throws IOException */ - public abstract boolean hasNext(V e, Strategy strat); + public abstract boolean hasNext(V e, Strategy strat) throws IOException; /** * @return a found vertex that can be read safely. diff --git a/graph/src/main/java/org/apache/hama/graph/ListVerticesInfo.java b/graph/src/main/java/org/apache/hama/graph/ListVerticesInfo.java index 5a14537dd..69fbb1a06 100644 --- a/graph/src/main/java/org/apache/hama/graph/ListVerticesInfo.java +++ b/graph/src/main/java/org/apache/hama/graph/ListVerticesInfo.java @@ -17,14 +17,18 @@ */ package org.apache.hama.graph; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; import java.io.IOException; import java.util.Iterator; -import java.util.SortedSet; -import java.util.TreeSet; +import java.util.Map; +import java.util.TreeMap; -import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; +import org.apache.hama.HamaConfiguration; import org.apache.hama.bsp.TaskAttemptID; /** @@ -36,52 +40,69 @@ */ public final class ListVerticesInfo<V extends WritableComparable<V>, E extends Writable, M extends Writable> implements VerticesInfo<V, E, M> { + private GraphJobRunner<V, E, M> runner; + Vertex<V, E, M> v; - private final SortedSet<Vertex<V, E, M>> vertices = new TreeSet<Vertex<V, E, M>>(); - // We will use this variable to make vertex removals, so we don't invoke GC too many times. - private final Vertex<V, E, M> vertexTemplate = GraphJobRunner.<V, E, M> newVertexInstance(GraphJobRunner.VERTEX_CLASS); + private final Map<V, byte[]> verticesMap = new TreeMap<V, byte[]>(); + + private ByteArrayOutputStream bos = null; + private DataOutputStream dos = null; + private ByteArrayInputStream bis = null; + private DataInputStream dis = null; + + @Override + public void init(GraphJobRunner<V, E, M> runner, HamaConfiguration conf, + TaskAttemptID attempt) throws IOException { + this.runner = runner; + } @Override - public void addVertex(Vertex<V, E, M> vertex) { - if (!vertices.add(vertex)) { - throw new UnsupportedOperationException("Vertex with ID: " + vertex.getVertexID() + " already exists!"); + public void addVertex(Vertex<V, E, M> vertex) throws IOException { + if (verticesMap.containsKey(vertex.getVertexID())) { + throw new UnsupportedOperationException("Vertex with ID: " + + vertex.getVertexID() + " already exists!"); + } else { + verticesMap.put(vertex.getVertexID(), serialize(vertex)); } } @Override public void removeVertex(V vertexID) throws UnsupportedOperationException { - vertexTemplate.setVertexID(vertexID); - - if (!vertices.remove(vertexTemplate)) { - throw new UnsupportedOperationException("Vertex with ID: " + vertexID + " not found on this peer."); + if (verticesMap.containsKey(vertexID)) { + verticesMap.remove(vertexID); + } else { + throw new UnsupportedOperationException("Vertex with ID: " + vertexID + + " not found on this peer."); } } public void clear() { - vertices.clear(); + verticesMap.clear(); } @Override public int size() { - return this.vertices.size(); + return this.verticesMap.size(); } @Override public IDSkippingIterator<V, E, M> skippingIterator() { return new IDSkippingIterator<V, E, M>() { - Iterator<Vertex<V, E, M>> it = vertices.iterator(); - Vertex<V, E, M> v; + Iterator<V> it = verticesMap.keySet().iterator(); @Override public boolean hasNext(V msgId, - org.apache.hama.graph.IDSkippingIterator.Strategy strat) { + org.apache.hama.graph.IDSkippingIterator.Strategy strat) + throws IOException { if (it.hasNext()) { - v = it.next(); + V vertexKey = it.next(); + v = deserialize(verticesMap.get(vertexKey)); while (!strat.accept(v, msgId)) { if (it.hasNext()) { - v = it.next(); + vertexKey = it.next(); + v = deserialize(verticesMap.get(vertexKey)); } else { return false; } @@ -97,7 +118,8 @@ public boolean hasNext(V msgId, @Override public Vertex<V, E, M> next() { if (v == null) { - throw new UnsupportedOperationException("You must invoke hasNext before ask for the next vertex."); + throw new UnsupportedOperationException( + "You must invoke hasNext before ask for the next vertex."); } Vertex<V, E, M> tmp = v; @@ -108,9 +130,27 @@ public Vertex<V, E, M> next() { }; } - @Override - public void finishVertexComputation(Vertex<V, E, M> vertex) { + public byte[] serialize(Vertex<V, E, M> vertex) throws IOException { + bos = new ByteArrayOutputStream(); + dos = new DataOutputStream(bos); + vertex.write(dos); + return bos.toByteArray(); + } + + public Vertex<V, E, M> deserialize(byte[] serialized) throws IOException { + bis = new ByteArrayInputStream(serialized); + dis = new DataInputStream(bis); + v = GraphJobRunner.<V, E, M> newVertexInstance(GraphJobRunner.VERTEX_CLASS); + v.readFields(dis); + v.setRunner(runner); + return v; + } + + @Override + public void finishVertexComputation(Vertex<V, E, M> vertex) + throws IOException { + verticesMap.put(vertex.getVertexID(), serialize(vertex)); } @Override @@ -122,13 +162,13 @@ public void finishAdditions() { public void finishRemovals() { } - @Override + @Override public void finishSuperstep() { } @Override - public void cleanup(Configuration conf, TaskAttemptID attempt) + public void cleanup(HamaConfiguration conf, TaskAttemptID attempt) throws IOException { } @@ -137,11 +177,4 @@ public void cleanup(Configuration conf, TaskAttemptID attempt) public void startSuperstep() throws IOException { } - - @Override - public void init(GraphJobRunner<V, E, M> runner, Configuration conf, - TaskAttemptID attempt) throws IOException { - - } - } diff --git a/graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java b/graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java index 9a0926306..f5ad67c4f 100644 --- a/graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java +++ b/graph/src/main/java/org/apache/hama/graph/OffHeapVerticesInfo.java @@ -27,9 +27,9 @@ import org.apache.directmemory.serialization.Serializer; import org.apache.directmemory.serialization.kryo.KryoSerializer; import org.apache.directmemory.utils.CacheValuesIterable; -import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; +import org.apache.hama.HamaConfiguration; import org.apache.hama.bsp.TaskAttemptID; import org.apache.hama.util.ReflectionUtils; @@ -37,123 +37,128 @@ * An off heap version of a {@link org.apache.hama.graph.Vertex} storage. */ public class OffHeapVerticesInfo<V extends WritableComparable<?>, E extends Writable, M extends Writable> - implements VerticesInfo<V, E, M> { - - public static final String DM_STRICT_ITERATOR = "dm.iterator.strict"; - public static final String DM_BUFFERS = "dm.buffers"; - public static final String DM_SIZE = "dm.size"; - public static final String DM_CAPACITY = "dm.capacity"; - public static final String DM_CONCURRENCY = "dm.concurrency"; - public static final String DM_DISPOSAL_TIME = "dm.disposal.time"; - public static final String DM_SERIALIZER = "dm.serializer"; - public static final String DM_SORTED = "dm.sorted"; - - private CacheService<V, Vertex<V, E, M>> vertices; - - private boolean strict; - private GraphJobRunner<V, E, M> runner; - - @Override - public void init(GraphJobRunner<V, E, M> runner, Configuration conf, TaskAttemptID attempt) throws IOException { - this.runner = runner; - this.strict = conf.getBoolean(DM_STRICT_ITERATOR, true); - DirectMemory<V, Vertex<V, E, M>> dm = new DirectMemory<V, Vertex<V, E, M>>() - .setNumberOfBuffers(conf.getInt(DM_BUFFERS, 100)) - .setSize(conf.getInt(DM_SIZE, 102400)) - .setSerializer(ReflectionUtils.newInstance(conf.getClass(DM_SERIALIZER, KryoSerializer.class, Serializer.class))) - .setDisposalTime(conf.getInt(DM_DISPOSAL_TIME, 3600000)); - if (conf.getBoolean(DM_SORTED, true)) { - dm.setMap(new ConcurrentSkipListMap<V, Pointer<Vertex<V, E, M>>>()); - } else { - dm.setInitialCapacity(conf.getInt(DM_CAPACITY, 1000)) - .setConcurrencyLevel(conf.getInt(DM_CONCURRENCY, 10)); - } + implements VerticesInfo<V, E, M> { + + public static final String DM_STRICT_ITERATOR = "dm.iterator.strict"; + public static final String DM_BUFFERS = "dm.buffers"; + public static final String DM_SIZE = "dm.size"; + public static final String DM_CAPACITY = "dm.capacity"; + public static final String DM_CONCURRENCY = "dm.concurrency"; + public static final String DM_DISPOSAL_TIME = "dm.disposal.time"; + public static final String DM_SERIALIZER = "dm.serializer"; + public static final String DM_SORTED = "dm.sorted"; + + private CacheService<V, Vertex<V, E, M>> vertices; + + private boolean strict; + private GraphJobRunner<V, E, M> runner; + + @Override + public void init(GraphJobRunner<V, E, M> runner, HamaConfiguration conf, + TaskAttemptID attempt) throws IOException { + this.runner = runner; + this.strict = conf.getBoolean(DM_STRICT_ITERATOR, true); + DirectMemory<V, Vertex<V, E, M>> dm = new DirectMemory<V, Vertex<V, E, M>>() + .setNumberOfBuffers(conf.getInt(DM_BUFFERS, 100)) + .setSize(conf.getInt(DM_SIZE, 102400)) + .setSerializer( + ReflectionUtils.newInstance(conf.getClass(DM_SERIALIZER, + KryoSerializer.class, Serializer.class))) + .setDisposalTime(conf.getInt(DM_DISPOSAL_TIME, 3600000)); + if (conf.getBoolean(DM_SORTED, true)) { + dm.setMap(new ConcurrentSkipListMap<V, Pointer<Vertex<V, E, M>>>()); + } else { + dm.setInitialCapacity(conf.getInt(DM_CAPACITY, 1000)) + .setConcurrencyLevel(conf.getInt(DM_CONCURRENCY, 10)); + } - this.vertices = dm.newCacheService(); + this.vertices = dm.newCacheService(); - } + } - @Override - public void cleanup(Configuration conf, TaskAttemptID attempt) throws IOException { - vertices.dump(); - } + @Override + public void cleanup(HamaConfiguration conf, TaskAttemptID attempt) + throws IOException { + vertices.dump(); + } - public void addVertex(Vertex<V, E, M> vertex) { - vertices.put(vertex.getVertexID(), vertex); - } + public void addVertex(Vertex<V, E, M> vertex) { + vertices.put(vertex.getVertexID(), vertex); + } - @Override - public void finishAdditions() { - } + @Override + public void finishAdditions() { + } - @Override - public void startSuperstep() throws IOException { - } + @Override + public void startSuperstep() throws IOException { + } - @Override - public void finishSuperstep() throws IOException { - } + @Override + public void finishSuperstep() throws IOException { + } - @Override - public void finishVertexComputation(Vertex<V, E, M> vertex) throws IOException { - vertices.put(vertex.getVertexID(), vertex); - } + @Override + public void finishVertexComputation(Vertex<V, E, M> vertex) + throws IOException { + vertices.put(vertex.getVertexID(), vertex); + } - public void clear() { - vertices.clear(); - } + public void clear() { + vertices.clear(); + } - public int size() { - return (int) this.vertices.entries(); - } + public int size() { + return (int) this.vertices.entries(); + } - @Override - public IDSkippingIterator<V, E, M> skippingIterator() { - final Iterator<Vertex<V, E, M>> vertexIterator = - new CacheValuesIterable<V, Vertex<V, E, M>>(vertices, strict).iterator(); - - return new IDSkippingIterator<V, E, M>() { - int currentIndex = 0; - - Vertex<V, E, M> currentVertex = null; - - @Override - public boolean hasNext(V e, - org.apache.hama.graph.IDSkippingIterator.Strategy strat) { - if (currentIndex < vertices.entries()) { - - Vertex<V, E, M> next = vertexIterator.next(); - while (!strat.accept(next, e)) { - currentIndex++; - } - currentVertex = next; - return true; - } else { - return false; - } - } - - @Override - public Vertex<V, E, M> next() { - currentIndex++; - if (currentVertex.getRunner() == null) { - currentVertex.setRunner(runner); - } - return currentVertex; - } - - }; + @Override + public IDSkippingIterator<V, E, M> skippingIterator() { + final Iterator<Vertex<V, E, M>> vertexIterator = new CacheValuesIterable<V, Vertex<V, E, M>>( + vertices, strict).iterator(); - } + return new IDSkippingIterator<V, E, M>() { + int currentIndex = 0; - @Override - public void removeVertex(V vertexID) { - throw new UnsupportedOperationException ("Not yet implemented"); - } + Vertex<V, E, M> currentVertex = null; - @Override - public void finishRemovals() { - throw new UnsupportedOperationException ("Not yet implemented"); - } + @Override + public boolean hasNext(V e, + org.apache.hama.graph.IDSkippingIterator.Strategy strat) { + if (currentIndex < vertices.entries()) { + + Vertex<V, E, M> next = vertexIterator.next(); + while (!strat.accept(next, e)) { + currentIndex++; + } + currentVertex = next; + return true; + } else { + return false; + } + } + + @Override + public Vertex<V, E, M> next() { + currentIndex++; + if (currentVertex.getRunner() == null) { + currentVertex.setRunner(runner); + } + return currentVertex; + } + + }; + + } + + @Override + public void removeVertex(V vertexID) { + throw new UnsupportedOperationException("Not yet implemented"); + } + + @Override + public void finishRemovals() { + throw new UnsupportedOperationException("Not yet implemented"); + } } diff --git a/graph/src/main/java/org/apache/hama/graph/Vertex.java b/graph/src/main/java/org/apache/hama/graph/Vertex.java index 3852e793e..a4d33147b 100644 --- a/graph/src/main/java/org/apache/hama/graph/Vertex.java +++ b/graph/src/main/java/org/apache/hama/graph/Vertex.java @@ -71,7 +71,7 @@ public V getVertexID() { @Override public void setup(HamaConfiguration conf) { } - + @Override public void sendMessage(Edge<V, E> e, M msg) throws IOException { runner.getPeer().send(getDestinationPeerName(e), @@ -172,7 +172,7 @@ public List<Edge<V, E>> getEdges() { @Override public M getValue() { - return value; + return this.value; } @Override @@ -306,10 +306,11 @@ public void readFields(DataInput in) throws IOException { } if (in.readBoolean()) { if (this.value == null) { - value = GraphJobRunner.createVertexValue(); + this.value = GraphJobRunner.createVertexValue(); } - value.readFields(in); + this.value.readFields(in); } + this.edges = new ArrayList<Edge<V, E>>(); if (in.readBoolean()) { int num = in.readInt(); @@ -340,6 +341,7 @@ public void write(DataOutput out) throws IOException { out.writeBoolean(true); vertexID.write(out); } + if (value == null) { out.writeBoolean(false); } else { diff --git a/graph/src/main/java/org/apache/hama/graph/VertexInterface.java b/graph/src/main/java/org/apache/hama/graph/VertexInterface.java index ca81f3587..6c94a57e7 100644 --- a/graph/src/main/java/org/apache/hama/graph/VertexInterface.java +++ b/graph/src/main/java/org/apache/hama/graph/VertexInterface.java @@ -38,7 +38,10 @@ public interface VertexInterface<V extends WritableComparable, E extends Writabl extends WritableComparable<VertexInterface<V, E, M>> { /** - * Used to setup a vertex. + * This method is called once before the Vertex computation begins. Since the + * Vertex object is serializable, variables in your Vertex program always + * should be declared a s static. + * */ public void setup(HamaConfiguration conf); @@ -78,12 +81,14 @@ public interface VertexInterface<V extends WritableComparable, E extends Writabl public void sendMessage(V destinationVertexID, M msg) throws IOException; /** - * Sends a message to add a new vertex through the partitioner to the appropriate BSP peer + * Sends a message to add a new vertex through the partitioner to the + * appropriate BSP peer */ - public void addVertex(V vertexID, List<Edge<V, E>> edges, M value) throws IOException; + public void addVertex(V vertexID, List<Edge<V, E>> edges, M value) + throws IOException; /** - * Removes current Vertex from local peer. + * Removes current Vertex from local peer. */ public void remove() throws IOException; diff --git a/graph/src/main/java/org/apache/hama/graph/VerticesInfo.java b/graph/src/main/java/org/apache/hama/graph/VerticesInfo.java index 6e510814f..987520ef0 100644 --- a/graph/src/main/java/org/apache/hama/graph/VerticesInfo.java +++ b/graph/src/main/java/org/apache/hama/graph/VerticesInfo.java @@ -19,9 +19,9 @@ import java.io.IOException; -import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.WritableComparable; +import org.apache.hama.HamaConfiguration; import org.apache.hama.bsp.TaskAttemptID; /** @@ -37,13 +37,13 @@ public interface VerticesInfo<V extends WritableComparable, E extends Writable, /** * Initialization of internal structures. */ - public void init(GraphJobRunner<V, E, M> runner, Configuration conf, + public void init(GraphJobRunner<V, E, M> runner, HamaConfiguration conf, TaskAttemptID attempt) throws IOException; /** * Cleanup of internal structures. */ - public void cleanup(Configuration conf, TaskAttemptID attempt) + public void cleanup(HamaConfiguration conf, TaskAttemptID attempt) throws IOException; /** @@ -92,5 +92,4 @@ public void finishVertexComputation(Vertex<V, E, M> vertex) public int size(); public IDSkippingIterator<V, E, M> skippingIterator(); - } diff --git a/graph/src/test/java/org/apache/hama/graph/TestDiskVerticesInfo.java b/graph/src/test/java/org/apache/hama/graph/TestDiskVerticesInfo.java index b9ae1bfc5..c922c86cd 100644 --- a/graph/src/test/java/org/apache/hama/graph/TestDiskVerticesInfo.java +++ b/graph/src/test/java/org/apache/hama/graph/TestDiskVerticesInfo.java @@ -22,10 +22,10 @@ import junit.framework.TestCase; -import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.DoubleWritable; import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.io.Text; +import org.apache.hama.HamaConfiguration; import org.apache.hama.bsp.TaskAttemptID; import org.apache.hama.graph.example.PageRank; import org.apache.hama.graph.example.PageRank.PageRankVertex; @@ -36,7 +36,7 @@ public class TestDiskVerticesInfo extends TestCase { @Test public void testDiskVerticesInfoLifeCycle() throws Exception { DiskVerticesInfo<Text, NullWritable, DoubleWritable> info = new DiskVerticesInfo<Text, NullWritable, DoubleWritable>(); - Configuration conf = new Configuration(); + HamaConfiguration conf = new HamaConfiguration(); conf.set(GraphJob.VERTEX_CLASS_ATTR, PageRankVertex.class.getName()); conf.set(GraphJob.VERTEX_EDGE_VALUE_CLASS_ATTR, NullWritable.class.getName()); diff --git a/graph/src/test/java/org/apache/hama/graph/TestOffHeapVerticesInfo.java b/graph/src/test/java/org/apache/hama/graph/TestOffHeapVerticesInfo.java index 1a0660c35..7dfa54662 100644 --- a/graph/src/test/java/org/apache/hama/graph/TestOffHeapVerticesInfo.java +++ b/graph/src/test/java/org/apache/hama/graph/TestOffHeapVerticesInfo.java @@ -17,28 +17,28 @@ */ package org.apache.hama.graph; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; import java.util.List; import java.util.Random; -import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.DoubleWritable; import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.io.Text; +import org.apache.hama.HamaConfiguration; import org.apache.hama.bsp.TaskAttemptID; import org.apache.hama.graph.example.PageRank.PageRankVertex; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - public class TestOffHeapVerticesInfo { @Test public void testOffHeapVerticesInfoLifeCycle() throws Exception { OffHeapVerticesInfo<Text, NullWritable, DoubleWritable> info = new OffHeapVerticesInfo<Text, NullWritable, DoubleWritable>(); - Configuration conf = new Configuration(); + HamaConfiguration conf = new HamaConfiguration(); conf.set(GraphJob.VERTEX_CLASS_ATTR, PageRankVertex.class.getName()); conf.set(GraphJob.VERTEX_EDGE_VALUE_CLASS_ATTR, NullWritable.class.getName()); @@ -121,7 +121,7 @@ public void testOffHeapVerticesInfoLifeCycle() throws Exception { public void testAdditionWithDefaults() throws Exception { OffHeapVerticesInfo<Text, NullWritable, DoubleWritable> verticesInfo = new OffHeapVerticesInfo<Text, NullWritable, DoubleWritable>(); - Configuration conf = new Configuration(); + HamaConfiguration conf = new HamaConfiguration(); verticesInfo.init(null, conf, null); Vertex<Text, NullWritable, DoubleWritable> vertex = new PageRankVertex(); vertex.setVertexID(new Text("some-id")); @@ -133,7 +133,7 @@ public void testAdditionWithDefaults() throws Exception { public void testMassiveAdditionWithDefaults() throws Exception { OffHeapVerticesInfo<Text, NullWritable, DoubleWritable> verticesInfo = new OffHeapVerticesInfo<Text, NullWritable, DoubleWritable>(); - Configuration conf = new Configuration(); + HamaConfiguration conf = new HamaConfiguration(); verticesInfo.init(null, conf, null); assertEquals("vertices info size should be 0 at startup", 0, verticesInfo.size()); Random r = new Random(); diff --git a/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusteringVertex.java b/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusteringVertex.java index ad6a28633..7bb27fbe8 100644 --- a/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusteringVertex.java +++ b/ml/src/main/java/org/apache/hama/ml/semiclustering/SemiClusteringVertex.java @@ -35,9 +35,9 @@ */ public class SemiClusteringVertex extends Vertex<Text, DoubleWritable, SemiClusterMessage> { - private int semiClusterMaximumVertexCount; - private int graphJobMessageSentCount; - private int graphJobVertexMaxClusterCount; + private static int semiClusterMaximumVertexCount; + private static int graphJobMessageSentCount; + private static int graphJobVertexMaxClusterCount; @Override public void setup(HamaConfiguration conf) {
747a478c6741b7e9e37bc00dbfe28ddc6982fb9b
orientdb
Issue -1604. Remote bag. Fix save notification.--
c
https://github.com/orientechnologies/orientdb
diff --git a/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java b/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java index fd5f344b74e..35a7ab18158 100755 --- a/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java +++ b/client/src/main/java/com/orientechnologies/orient/client/remote/OStorageRemote.java @@ -85,6 +85,7 @@ import com.orientechnologies.orient.core.storage.OStorageAbstract; import com.orientechnologies.orient.core.storage.OStorageOperationResult; import com.orientechnologies.orient.core.storage.OStorageProxy; +import com.orientechnologies.orient.core.storage.impl.local.paginated.ORecordSerializationContext; import com.orientechnologies.orient.core.tx.OTransaction; import com.orientechnologies.orient.core.tx.OTransactionAbstract; import com.orientechnologies.orient.core.version.ORecordVersion; @@ -1170,7 +1171,8 @@ private void readCollectionChanges(OChannelBinaryAsynchClient network) throws IO collectionManager.updateCollectionPointer(new UUID(mBitsOfId, lBitsOfId), pointer); } - collectionManager.clearPendingCollections(); + if (ORecordSerializationContext.getDepth() <= 1) + collectionManager.clearPendingCollections(); } public void rollback(OTransaction iTx) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationContext.java b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationContext.java index 0ef0bcdfe0f..1fd4504ee53 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationContext.java +++ b/core/src/main/java/com/orientechnologies/orient/core/storage/impl/local/paginated/ORecordSerializationContext.java @@ -31,6 +31,10 @@ protected Deque<ORecordSerializationContext> initialValue() { } }; + public static int getDepth() { + return ORecordSerializationContext.SERIALIZATION_CONTEXT_STACK.get().size(); + } + public static ORecordSerializationContext pushContext() { final Deque<ORecordSerializationContext> stack = SERIALIZATION_CONTEXT_STACK.get(); final ORecordSerializationContext context = new ORecordSerializationContext(); @@ -66,4 +70,4 @@ void executeOperations(OLocalPaginatedStorage storage) { operation.execute(storage); } } -} \ No newline at end of file +} diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ORidBagTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ORidBagTest.java index 2e43b1706d9..27a55faefb9 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ORidBagTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ORidBagTest.java @@ -1159,10 +1159,10 @@ private void massiveInsertionIteration(Random rnd, List<OIdentifiable> rids, ORi while (bagIterator.hasNext()) { OIdentifiable bagValue = bagIterator.next(); - Assert.assertTrue(rids.contains(bagValue)); + Assert.assertTrue(rids.contains(bagValue)); } - Assert.assertEquals(bag.size(), rids.size()); + Assert.assertEquals(bag.size(), rids.size()); for (int i = 0; i < 100; i++) { if (rnd.nextDouble() < 0.2 & rids.size() > 5) { @@ -1183,20 +1183,20 @@ private void massiveInsertionIteration(Random rnd, List<OIdentifiable> rids, ORi while (bagIterator.hasNext()) { final OIdentifiable bagValue = bagIterator.next(); - Assert.assertTrue(rids.contains(bagValue)); + Assert.assertTrue(rids.contains(bagValue)); if (rnd.nextDouble() < 0.05) { bagIterator.remove(); - Assert.assertTrue(rids.remove(bagValue)); + Assert.assertTrue(rids.remove(bagValue)); } } - Assert.assertEquals(bag.size(), rids.size()); + Assert.assertEquals(bag.size(), rids.size()); bagIterator = bag.iterator(); while (bagIterator.hasNext()) { - final OIdentifiable bagValue = bagIterator.next(); - Assert.assertTrue(rids.contains(bagValue)); + final OIdentifiable bagValue = bagIterator.next(); + Assert.assertTrue(rids.contains(bagValue)); } } @@ -1277,83 +1277,83 @@ public void testDocumentHelper() { public void testAddNewItemsAndRemoveThem() { final List<OIdentifiable> rids = new ArrayList<OIdentifiable>(); ORidBag ridBag = new ORidBag(); - for (int i = 0; i < 10; i++) { + int size = 0; + for (int i = 0; i < 0; i++) { ODocument docToAdd = new ODocument(); for (int k = 0; k < 2; k++) { ridBag.add(docToAdd); rids.add(docToAdd); + size++; } - } - Assert.assertEquals(ridBag.size(), 20); + Assert.assertEquals(ridBag.size(), size); ODocument document = new ODocument(); document.field("ridBag", ridBag); document.save(); document = database.load(document.getIdentity(), "*:-1", true); ridBag = document.field("ridBag"); - Assert.assertEquals(ridBag.size(), 20); + Assert.assertEquals(ridBag.size(), size); final List<OIdentifiable> newDocs = new ArrayList<OIdentifiable>(); - for (int i = 0; i < 10; i++) { + for (int i = 0; i < 1; i++) { ODocument docToAdd = new ODocument(); for (int k = 0; k < 2; k++) { ridBag.add(docToAdd); rids.add(docToAdd); newDocs.add(docToAdd); + size++; } } - Assert.assertEquals(ridBag.size(), 40); + Assert.assertEquals(ridBag.size(), size); Random rnd = new Random(); - int size = 40; - - for (int i = 0; i < 10; i++) { - if (rnd.nextBoolean()) { - OIdentifiable newDoc = newDocs.get(i); - rids.remove(newDoc); - ridBag.remove(newDoc); - newDocs.remove(newDoc); + // for (int i = 0; i < newDocs.size(); i++) { + // if (rnd.nextBoolean()) { + // OIdentifiable newDoc = newDocs.get(i); + // rids.remove(newDoc); + // ridBag.remove(newDoc); + // newDocs.remove(newDoc); + // + // size--; + // } + // } + // + // for (OIdentifiable identifiable : ridBag) { + // if (newDocs.contains(identifiable) && rnd.nextBoolean()) { + // ridBag.remove(identifiable); + // rids.remove(identifiable); + // + // size--; + // } + // } - size--; - } - } + Assert.assertEquals(ridBag.size(), size); + List<OIdentifiable> ridsCopy = new ArrayList<OIdentifiable>(rids); for (OIdentifiable identifiable : ridBag) { - if (newDocs.contains(identifiable) && rnd.nextBoolean()) { - ridBag.remove(identifiable); - rids.remove(identifiable); - - size--; - } + Assert.assertTrue(rids.remove(identifiable)); } - Assert.assertEquals(ridBag.size(), size); - List<OIdentifiable> ridsCopy = new ArrayList<OIdentifiable>(rids); - - for (OIdentifiable identifiable : ridBag) { - Assert.assertTrue(rids.remove(identifiable)); - } - - Assert.assertTrue(rids.isEmpty()); + Assert.assertTrue(rids.isEmpty()); - document.save(); + document.save(); - document = database.load(document.getIdentity(), "*:-1", false); - ridBag = document.field("ridBag"); + document = database.load(document.getIdentity(), "*:-1", false); + ridBag = document.field("ridBag"); - rids.addAll(ridsCopy); - for (OIdentifiable identifiable : ridBag) { - Assert.assertTrue(rids.remove(identifiable)); - } + rids.addAll(ridsCopy); + for (OIdentifiable identifiable : ridBag) { + Assert.assertTrue(rids.remove(identifiable)); + } - Assert.assertTrue(rids.isEmpty()); - Assert.assertEquals(ridBag.size(), size); + Assert.assertTrue(rids.isEmpty()); + Assert.assertEquals(ridBag.size(), size); } public void testJsonSerialization() {
be724da23f0c63da3e4d517380b9fe8c3916a810
agorava$agorava-core
AGOVA-35 Add support for Weld 2.0 * ProcessBean<X> changed to ProcessBean<? extends X> * Calls to BeanManager.getBeans not allowed until AfterDeploymentValidation Works on both weld-1.x, weld-2.x and owb profiles. Changed to use JavaArchive in @Deployment instead of GenericArchive due to bad assumption in OpenWebBeans container: https://issues.apache.org/jira/browse/OWB-880
a
https://github.com/agorava/agorava-core
diff --git a/agorava-core-impl-cdi/pom.xml b/agorava-core-impl-cdi/pom.xml index b5bf8c0..2d7dde6 100644 --- a/agorava-core-impl-cdi/pom.xml +++ b/agorava-core-impl-cdi/pom.xml @@ -137,9 +137,9 @@ </profile> <profile> - <id>weld</id> + <id>weld-1.x</id> - <!-- use this profile to compile and test Agorava with Weld --> + <!-- use this profile to compile and test Agorava with Weld 1 --> <activation> <activeByDefault>true</activeByDefault> <property> @@ -148,7 +148,6 @@ </property> </activation> - <properties> <arquillian>weld-ee-embedded-1.1</arquillian> </properties> @@ -175,6 +174,42 @@ </profile> + <profile> + <id>weld-2.x</id> + + <!-- use this profile to compile and test Agorava with Weld 2 --> + <activation> + <property> + <name>arquillian</name> + <value>weld-ee-embedded-1.1</value> + </property> + </activation> + + <properties> + <arquillian>weld-ee-embedded-1.1</arquillian> + </properties> + <dependencies> + <dependency> + <groupId>org.jboss.spec</groupId> + <artifactId>jboss-javaee-6.0</artifactId> + <type>pom</type> + </dependency> + <dependency> + <groupId>org.jboss.arquillian.container</groupId> + <artifactId>arquillian-weld-ee-embedded-1.1</artifactId> + </dependency> + <dependency> + <groupId>org.jboss.weld</groupId> + <artifactId>weld-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-simple</artifactId> + </dependency> + </dependencies> + + </profile> </profiles> <build> diff --git a/agorava-core-impl-cdi/src/main/java/org/agorava/core/cdi/AgoravaExtension.java b/agorava-core-impl-cdi/src/main/java/org/agorava/core/cdi/AgoravaExtension.java index 0eb6134..21a6e7a 100644 --- a/agorava-core-impl-cdi/src/main/java/org/agorava/core/cdi/AgoravaExtension.java +++ b/agorava-core-impl-cdi/src/main/java/org/agorava/core/cdi/AgoravaExtension.java @@ -16,22 +16,10 @@ package org.agorava.core.cdi; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import com.google.common.collect.Iterables; -import org.agorava.core.api.*; -import org.agorava.core.api.exception.AgoravaException; -import org.agorava.core.api.oauth.OAuthAppSettings; -import org.agorava.core.oauth.OAuthSessionImpl; -import org.agorava.core.oauth.scribe.OAuthProviderScribe; -import org.apache.deltaspike.core.util.bean.BeanBuilder; -import org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder; +import static com.google.common.collect.Sets.newHashSet; +import static java.util.logging.Level.INFO; +import static java.util.logging.Level.WARNING; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.Dependent; -import javax.enterprise.context.spi.CreationalContext; -import javax.enterprise.event.Observes; -import javax.enterprise.inject.spi.*; import java.io.Serializable; import java.lang.annotation.Annotation; import java.lang.reflect.Type; @@ -41,9 +29,45 @@ import java.util.Set; import java.util.logging.Logger; -import static com.google.common.collect.Sets.newHashSet; -import static java.util.logging.Level.INFO; -import static java.util.logging.Level.WARNING; +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.Dependent; +import javax.enterprise.context.spi.CreationalContext; +import javax.enterprise.event.Observes; +import javax.enterprise.inject.Any; +import javax.enterprise.inject.spi.AfterBeanDiscovery; +import javax.enterprise.inject.spi.AfterDeploymentValidation; +import javax.enterprise.inject.spi.Annotated; +import javax.enterprise.inject.spi.AnnotatedConstructor; +import javax.enterprise.inject.spi.AnnotatedField; +import javax.enterprise.inject.spi.AnnotatedMember; +import javax.enterprise.inject.spi.AnnotatedMethod; +import javax.enterprise.inject.spi.AnnotatedType; +import javax.enterprise.inject.spi.Bean; +import javax.enterprise.inject.spi.BeanManager; +import javax.enterprise.inject.spi.BeforeBeanDiscovery; +import javax.enterprise.inject.spi.Extension; +import javax.enterprise.inject.spi.ProcessAnnotatedType; +import javax.enterprise.inject.spi.ProcessBean; +import javax.enterprise.inject.spi.ProcessProducer; +import javax.enterprise.inject.spi.ProcessProducerMethod; +import javax.enterprise.inject.spi.Producer; +import javax.enterprise.util.AnnotationLiteral; + +import org.agorava.core.api.ApplyQualifier; +import org.agorava.core.api.GenericRoot; +import org.agorava.core.api.Injectable; +import org.agorava.core.api.RemoteApi; +import org.agorava.core.api.ServiceRelated; +import org.agorava.core.api.exception.AgoravaException; +import org.agorava.core.api.oauth.OAuthAppSettings; +import org.agorava.core.oauth.OAuthSessionImpl; +import org.agorava.core.oauth.scribe.OAuthProviderScribe; +import org.apache.deltaspike.core.util.bean.BeanBuilder; +import org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder; + +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.Iterables; /** * Agorava CDI extension to discover existing module and configured modules @@ -52,6 +76,8 @@ */ public class AgoravaExtension implements Extension, Serializable { + private static final long serialVersionUID = 1L; + private static final Set<Annotation> servicesQualifiersConfigured = newHashSet(); private static Logger log = Logger.getLogger(AgoravaExtension.class.getName()); private static BiMap<String, Annotation> servicesToQualifier = HashBiMap.create(); @@ -104,8 +130,12 @@ public static void setMultiSession(boolean ms) { * no matching meta-annotation was found. */ public static Set<Annotation> getAnnotationsWithMeta(Annotated element, final Class<? extends Annotation> metaAnnotationType) { + return getAnnotationsWithMeta(element.getAnnotations(), metaAnnotationType); + } + + public static Set<Annotation> getAnnotationsWithMeta(Set<Annotation> qualifiers, final Class<? extends Annotation> metaAnnotationType) { Set<Annotation> annotations = new HashSet<Annotation>(); - for (Annotation annotation : element.getAnnotations()) { + for (Annotation annotation : qualifiers) { if (annotation.annotationType().isAnnotationPresent(metaAnnotationType)) { annotations.add(annotation); } @@ -185,19 +215,20 @@ private <T> void processGenericAnnotatedType(ProcessAnnotatedType<T> pat) { pat.setAnnotatedType(atb.create()); } - } else + } else { pat.veto(); + } } - public void processGenericOauthService(@Observes ProcessAnnotatedType<OAuthServiceImpl> pat) { + public void processGenericOauthService(@Observes ProcessAnnotatedType<? extends OAuthServiceImpl> pat) { processGenericAnnotatedType(pat); } - public void processGenericOauthProvider(@Observes ProcessAnnotatedType<OAuthProviderScribe> pat) { + public void processGenericOauthProvider(@Observes ProcessAnnotatedType<? extends OAuthProviderScribe> pat) { processGenericAnnotatedType(pat); } - public void processGenericSession(@Observes ProcessAnnotatedType<OAuthSessionImpl> pat) { + public void processGenericSession(@Observes ProcessAnnotatedType<? extends OAuthSessionImpl> pat) { processGenericAnnotatedType(pat); } @@ -242,30 +273,24 @@ public void processOAuthSettingsProducer(@Observes final ProcessProducer<?, OAut //----------------- Process Bean Phase ---------------------------------- - private void CommonsProcessRemoteService(ProcessBean<RemoteApi> pb, BeanManager beanManager) { - CreationalContext ctx = beanManager.createCreationalContext(null); + /* + * This does practically not do much anymore after the discovery was moved + * to AfterDeploymentValidation. see https://issues.jboss.org/browse/CDI-274 + * Kept around to do simple deployment validation of ServiceRelated qualifier. + */ + private void CommonsProcessRemoteService(ProcessBean<? extends RemoteApi> pb) { Annotated annotated = pb.getAnnotated(); Set<Annotation> qualifiers = AgoravaExtension.getAnnotationsWithMeta(annotated, ServiceRelated.class); if (qualifiers.size() != 1) throw new AgoravaException("A RemoteService bean should have one and only one service related Qualifier : " + pb.getAnnotated().toString()); - Annotation qual = Iterables.getOnlyElement(qualifiers); - log.log(INFO, "Found new service related qualifier : {0}", qual); - - Bean<?> beanSoc = pb.getBean(); - - final RemoteApi smah = (RemoteApi) beanManager.getReference(beanSoc, RemoteApi.class, ctx); - String name = smah.getServiceName(); - servicesToQualifier.put(name, qual); - - ctx.release(); } - public void processRemoteServiceRoot(@Observes ProcessBean<RemoteApi> pb, BeanManager beanManager) { - CommonsProcessRemoteService(pb, beanManager); + public void processRemoteServiceRoot(@Observes ProcessBean<? extends RemoteApi> pb) { + CommonsProcessRemoteService(pb); } - public void processRemoteServiceRoot(@Observes ProcessProducerMethod<RemoteApi, ?> pb, BeanManager beanManager) { - CommonsProcessRemoteService((ProcessBean<RemoteApi>) pb, beanManager); + public void processRemoteServiceRoot(@Observes ProcessProducerMethod<? extends RemoteApi, ?> pb) { + CommonsProcessRemoteService((ProcessBean<? extends RemoteApi>) pb); } @@ -320,9 +345,28 @@ public void registerGenericBeans(@Observes AfterBeanDiscovery abd, BeanManager b //--------------------- After Deployment validation phase - public void endOfExtension(@Observes AfterDeploymentValidation adv) { + public void endOfExtension(@Observes AfterDeploymentValidation adv, BeanManager beanManager) { + + registerServiceNames(beanManager); + log.info("Agorava initialization complete"); } + private void registerServiceNames(BeanManager beanManager) { + Set<Bean<?>> beans = beanManager.getBeans(RemoteApi.class, new AnyLiteral()); + + for(Bean<?> bean : beans) { + Set<Annotation> qualifiers = getAnnotationsWithMeta(bean.getQualifiers(), ServiceRelated.class); + Annotation qual = Iterables.getOnlyElement(qualifiers); + CreationalContext<?> ctx = beanManager.createCreationalContext(null); + final RemoteApi smah = (RemoteApi) beanManager.getReference(bean, RemoteApi.class, ctx); + String name = smah.getServiceName(); + servicesToQualifier.put(name, qual); + ctx.release(); + } + } + public static class AnyLiteral extends AnnotationLiteral<Any> implements Any { + private static final long serialVersionUID = 1L; + } } diff --git a/agorava-core-impl-cdi/src/test/java/org/agorava/core/cdi/test/AgoravaTestDeploy.java b/agorava-core-impl-cdi/src/test/java/org/agorava/core/cdi/test/AgoravaTestDeploy.java index ac2da49..418debf 100644 --- a/agorava-core-impl-cdi/src/test/java/org/agorava/core/cdi/test/AgoravaTestDeploy.java +++ b/agorava-core-impl-cdi/src/test/java/org/agorava/core/cdi/test/AgoravaTestDeploy.java @@ -16,15 +16,18 @@ package org.agorava.core.cdi.test; +import java.io.FileNotFoundException; + import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.shrinkwrap.api.*; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ArchivePath; +import org.jboss.shrinkwrap.api.Filter; +import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.resolver.api.maven.Maven; -import java.io.FileNotFoundException; - /** * Created with IntelliJ IDEA. * User: antoine @@ -45,10 +48,10 @@ public boolean include(ArchivePath path) { .addAsResource("META-INF/services/javax.enterprise.inject.spi.Extension") .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); - GenericArchive[] libs = Maven.resolver() + JavaArchive[] libs = Maven.resolver() .loadPomFromFile("pom.xml") .resolve("org.apache.deltaspike.core:deltaspike-core-impl") - .withTransitivity().as(GenericArchive.class); + .withTransitivity().as(JavaArchive.class); WebArchive ret = ShrinkWrap
5a2052fad3f92e6675ba6362028f5f5851934f01
camel
CAMEL-4059: Fixed test on windows--git-svn-id: https://svn.apache.org/repos/asf/camel/trunk@1132659 13f79535-47bb-0310-9956-ffa450edef68-
c
https://github.com/apache/camel
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTestConnectionOnStartupTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTestConnectionOnStartupTest.java index 8b24f76a2c209..045aed17b0efd 100644 --- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTestConnectionOnStartupTest.java +++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTestConnectionOnStartupTest.java @@ -46,7 +46,6 @@ public void configure() throws Exception { context.start(); fail("Should have thrown an exception"); } catch (FailedToCreateConsumerException e) { - // expected assertEquals("Failed to create Consumer for endpoint: Endpoint[activemq://queue:foo?testConnectionOnStartup=true]. " + "Reason: Cannot get JMS Connection on startup for destination foo", e.getMessage()); } @@ -65,12 +64,8 @@ public void configure() throws Exception { context.start(); fail("Should have thrown an exception"); } catch (FailedToCreateProducerException e) { - // expected - assertEquals("Failed to create Producer for endpoint: Endpoint[activemq://queue:foo?testConnectionOnStartup=true]. " - + "Reason: org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: " - + "Endpoint[activemq://queue:foo?testConnectionOnStartup=true]. Reason: javax.jms.JMSException: " - + "Could not connect to broker URL: tcp://localhost:61111. Reason: java.net.ConnectException: Connection refused", - e.getMessage()); + assertTrue(e.getMessage().startsWith("Failed to create Producer for endpoint: Endpoint[activemq://queue:foo?testConnectionOnStartup=true].")); + assertTrue(e.getMessage().contains("java.net.ConnectException")); } }
f5a3477fe1bd136a3f9f7e2048299ad24bd47ded
Valadoc
gtkdoc-importer: Add support for computeroutput
a
https://github.com/GNOME/vala/
diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/src/libvaladoc/documentation/gtkdoccommentparser.vala index 966fe9d3e2..91d395bb1e 100644 --- a/src/libvaladoc/documentation/gtkdoccommentparser.vala +++ b/src/libvaladoc/documentation/gtkdoccommentparser.vala @@ -1260,6 +1260,8 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { append_inline_content_not_null (run, parse_highlighted_template ("application", Run.Style.MONOSPACED)); } else if (current.type == TokenType.XML_OPEN && current.content == "varname") { append_inline_content_not_null (run, parse_highlighted_template ("varname", Run.Style.MONOSPACED)); + } else if (current.type == TokenType.XML_OPEN && current.content == "computeroutput") { + append_inline_content_not_null (run, parse_highlighted_template ("computeroutput", Run.Style.MONOSPACED)); } else if (current.type == TokenType.XML_OPEN && current.content == "emphasis") { append_inline_content_not_null (run, parse_highlighted_template ("emphasis", Run.Style.MONOSPACED)); } else if (current.type == TokenType.XML_OPEN && current.content == "pre") {
2bc4b792bc22fe387d00637ecdd1c78a8950d692
Vala
sqlite3: add wrapper methods for sqlite3_exec and sqlite3_get_table Fixes bug 579364.
c
https://github.com/GNOME/vala/
diff --git a/vapi/sqlite3.vapi b/vapi/sqlite3.vapi index 1e725e09d0..43d71e0907 100644 --- a/vapi/sqlite3.vapi +++ b/vapi/sqlite3.vapi @@ -28,22 +28,52 @@ namespace Sqlite { public class Database { public int busy_timeout (int ms); public int changes (); - public int exec (string sql, Callback? sqlite3_callback = null, out string errmsg = null); + [CCode (cname = "sqlite3_exec")] + private int _exec (string sql, Callback? sqlite3_callback = null, out unowned string errmsg = null); + [CCode (cname = "_vala_sqlite3_exec")] + public int exec (string sql, Callback? sqlite3_callback = null, out string errmsg = null) { + unowned string sqlite_errmsg; + var ec = this._exec (sql, sqlite3_callback, out sqlite_errmsg); + if (sqlite_errmsg != null) { + errmsg = sqlite_errmsg; + Sqlite.Memory.free ((void*) sqlite_errmsg); + } + return ec; + } public int extended_result_codes (int onoff); public int get_autocommit (); public void interrupt (); public int64 last_insert_rowid (); public int total_changes (); - public int complete (string sql); - public int get_table (string sql, [CCode (array_length = false)] out unowned string[] resultp, out int nrow, out int ncolumn, out string errmsg); - public static void free_table ([CCode (array_length = false)] string[] result); + [CCode (cname = "sqlite3_get_table")] + private int _get_table (string sql, [CCode (array_length = false)] out unowned string[] resultp, out int nrow, out int ncolumn, out unowned string? errmsg = null); + private static void free_table ([CCode (array_length = false)] string[] result); + [CCode (cname = "_vala_sqlite3_get_table")] + public int get_table (string sql, out string[] resultp, out int nrow, out int ncolumn, out string? errmsg = null) { + unowned string sqlite_errmsg; + unowned string[] sqlite_resultp; + + var ec = this._get_table (sql, out sqlite_resultp, out nrow, out ncolumn, out sqlite_errmsg); + + resultp = new string[(nrow + 1) * ncolumn]; + for (var entry = 0 ; entry < resultp.length ; entry++ ) { + resultp[entry] = sqlite_resultp[entry]; + } + Sqlite.Database.free_table (sqlite_resultp); + + if (sqlite_errmsg != null) { + errmsg = sqlite_errmsg; + Sqlite.Memory.free ((void*) sqlite_errmsg); + } + return ec; + } public static int open (string filename, out Database db); public static int open_v2 (string filename, out Database db, int flags = OPEN_READWRITE | OPEN_CREATE, string? zVfs = null); public int errcode (); public unowned string errmsg (); - public int prepare (string sql, int n_bytes, out Statement stmt, out string tail = null); - public int prepare_v2 (string sql, int n_bytes, out Statement stmt, out string tail = null); + public int prepare (string sql, int n_bytes, out Statement stmt, out unowned string tail = null); + public int prepare_v2 (string sql, int n_bytes, out Statement stmt, out unowned string tail = null); public void trace (TraceCallback? xtrace); public void profile (ProfileCallback? xprofile); public void progress_handler (int n_opcodes, Sqlite.ProgressCallback? progress_handler); @@ -234,6 +264,15 @@ namespace Sqlite { public unowned string sql (); } + namespace Memory { + [CCode (cname = "sqlite3_malloc")] + public static void* malloc (int n_bytes); + [CCode (cname = "sqlite3_realloc")] + public static void* realloc (void* mem, int n_bytes); + [CCode (cname = "sqlite3_free")] + public static void free (void* mem); + } + [Compact] [CCode (cname = "sqlite3_mutex")] public class Mutex {
b0d00c5b3003a233c793a0f092f15358530a0acb
orientdb
Implemented new commands: - truncate cluster -- truncate class--
a
https://github.com/orientechnologies/orientdb
diff --git a/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java b/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java index b64c9f90d29..bbd44e84cc6 100644 --- a/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java +++ b/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java @@ -177,10 +177,14 @@ public void createDatabase( @ConsoleCommand(description = "Create a new cluster in the current database. The cluster can be physical or logical.") public void createCluster( @ConsoleParameter(name = "cluster-name", description = "The name of the cluster to create") String iClusterName, - @ConsoleParameter(name = "cluster-type", description = "Cluster type: 'physical' or 'logical'") String iClusterType) { + @ConsoleParameter(name = "cluster-type", description = "Cluster type: 'physical' or 'logical'") String iClusterType, + @ConsoleParameter(name = "position", description = "cluster id to replace an empty position or 'append' to append at the end") String iPosition) { checkCurrentDatabase(); - out.println("Creating cluster [" + iClusterName + "] of type '" + iClusterType + "' in database " + currentDatabaseName + "..."); + final int position = iPosition.toUpperCase().equals("append") ? -1 : Integer.parseInt(iPosition); + + out.println("Creating cluster [" + iClusterName + "] of type '" + iClusterType + "' in database " + currentDatabaseName + + (position == -1 ? " as last one" : " in place of #" + position) + "..."); int clusterId = iClusterType.equalsIgnoreCase("physical") ? currentDatabase.addPhysicalCluster(iClusterName, iClusterName, -1) : currentDatabase.addLogicalCluster(iClusterName, currentDatabase.getClusterIdByName(OStorage.CLUSTER_INTERNAL_NAME)); @@ -226,7 +230,7 @@ public void truncateCluster( cluster.truncate(); - out.println("Truncated " + recs + "records from cluster [" + iClusterName + "] in database " + currentDatabaseName); + out.println("Truncated " + recs + " records from cluster [" + iClusterName + "] in database " + currentDatabaseName); } catch (Exception e) { out.println("ERROR: " + e.toString()); } @@ -245,7 +249,7 @@ public void truncateClass( cls.truncate(); - out.println("Truncated " + recs + "records from class [" + iClassName + "] in database " + currentDatabaseName); + out.println("Truncated " + recs + " records from class [" + iClassName + "] in database " + currentDatabaseName); } catch (Exception e) { out.println("ERROR: " + e.toString()); }
7023a531dffa5d167bada9a33b87e8dbd98dc628
Vala
girparser: improve support for generic type arguments
a
https://github.com/GNOME/vala/
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala index 11a58c2ba5..8cd241d6b4 100644 --- a/vala/valagirparser.vala +++ b/vala/valagirparser.vala @@ -348,8 +348,9 @@ public class Vala.GirParser : CodeVisitor { string transfer = reader.get_attribute ("transfer-ownership"); string allow_none = reader.get_attribute ("allow-none"); next (); - var type = &ctype != null ? parse_type(out ctype) : parse_type (); - if (transfer == "full") { + var transfer_elements = transfer == "full"; + var type = &ctype != null ? parse_type(out ctype, null, transfer_elements) : parse_type (null, null, transfer_elements); + if (transfer == "full" || transfer == "container") { type.value_owned = true; } if (allow_none == "1") { @@ -394,8 +395,8 @@ public class Vala.GirParser : CodeVisitor { param = new FormalParameter.with_ellipsis (get_current_src ()); end_element ("varargs"); } else { - var type = parse_type (null, out array_length_idx); - if (transfer == "full") { + var type = parse_type (null, out array_length_idx, transfer == "full"); + if (transfer == "full" || transfer == "container") { type.value_owned = true; } if (allow_none == "1") { @@ -412,7 +413,7 @@ public class Vala.GirParser : CodeVisitor { return param; } - DataType parse_type (out string? ctype = null, out int array_length_index = null) { + DataType parse_type (out string? ctype = null, out int array_length_index = null, bool transfer_elements = false) { if (reader.name == "array") { start_element ("array"); if (reader.get_attribute ("length") != null @@ -436,7 +437,9 @@ public class Vala.GirParser : CodeVisitor { // type arguments / element types while (current_token == MarkupTokenType.START_ELEMENT) { - parse_type (); + var element_type = parse_type (); + element_type.value_owned = transfer_elements; + type.add_type_argument (element_type); } end_element ("type");
0ea33300e63850254f9490588b6e41042f281d0f
drools
JBRULES-3126 NPE when retracting an object with a- collection field which has been accumulated on--
c
https://github.com/kiegroup/drools
diff --git a/drools-compiler/src/test/java/org/drools/integrationtests/AccumulateTest.java b/drools-compiler/src/test/java/org/drools/integrationtests/AccumulateTest.java index 4958c657043..8a5528e359e 100644 --- a/drools-compiler/src/test/java/org/drools/integrationtests/AccumulateTest.java +++ b/drools-compiler/src/test/java/org/drools/integrationtests/AccumulateTest.java @@ -18,7 +18,6 @@ import java.util.List; import java.util.Set; -import junit.framework.Assert; import org.drools.Cheese; import org.drools.Cheesery; import org.drools.FactHandle; @@ -1904,19 +1903,16 @@ public void testAccumulateAndRetract() { kbuilder.add( ResourceFactory.newByteArrayResource(drl.getBytes()), ResourceType.DRL ); if (kbuilder.hasErrors()) { - System.err.println(kbuilder.getErrors()); - Assert.fail(kbuilder.getErrors().toString()); + fail(kbuilder.getErrors().toString()); } KnowledgeBase kb = KnowledgeBaseFactory.newKnowledgeBase(); kb.addKnowledgePackages(kbuilder.getKnowledgePackages()); StatefulKnowledgeSession ks = kb.newStatefulKnowledgeSession(); - ArrayList resList = new ArrayList(); ks.setGlobal("list",resList); - ArrayList<String> list = new ArrayList<String>(); list.add("x"); list.add("y"); @@ -1925,7 +1921,7 @@ public void testAccumulateAndRetract() { ks.insert(list); ks.fireAllRules(); - Assert.assertEquals(3L, resList.get(0)); + assertEquals(3L, resList.get(0)); }
ce554e2810317d96078e68b4ab9379efe4c8db61
Vala
vapigen: Improve support for type_arguments Fixes bug 609693.
a
https://github.com/GNOME/vala/
diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala index 72f10179bd..e25515755f 100644 --- a/vapigen/valagidlparser.vala +++ b/vapigen/valagidlparser.vala @@ -376,6 +376,11 @@ public class Vala.GIdlParser : CodeVisitor { if (eval (nv[1]) == "1") { param_type.nullable = true; } + } else if (nv[0] == "type_arguments") { + var type_args = eval (nv[1]).split (","); + foreach (string type_arg in type_args) { + param_type.add_type_argument (get_type_from_string (type_arg)); + } } } } @@ -1462,7 +1467,26 @@ public class Vala.GIdlParser : CodeVisitor { return type; } - + + public UnresolvedType? get_type_from_string (string type_arg) { + bool is_unowned = false; + UnresolvedSymbol? sym = null; + + if ( type_arg.has_prefix ("unowned ") ) { + type_arg = type_arg.offset ("unowned ".len ()); + is_unowned = true; + } + + foreach (unowned string s in type_arg.split (".")) { + sym = new UnresolvedSymbol (sym, s); + } + + var arg_type = new UnresolvedType.from_symbol (sym); + arg_type.value_owned = !is_unowned; + + return arg_type; + } + private Method? create_method (string name, string symbol, IdlNodeParam? res, GLib.List<IdlNodeParam>? parameters, bool is_constructor, bool is_interface) { DataType return_type = null; if (res != null) { @@ -1570,9 +1594,7 @@ public class Vala.GIdlParser : CodeVisitor { } else if (nv[0] == "type_arguments") { var type_args = eval (nv[1]).split (","); foreach (string type_arg in type_args) { - var arg_type = new UnresolvedType.from_symbol (new UnresolvedSymbol (null, type_arg)); - arg_type.value_owned = true; - return_type.add_type_argument (arg_type); + return_type.add_type_argument (get_type_from_string (type_arg)); } } else if (nv[0] == "cheader_filename") { m.add_cheader_filename (eval (nv[1])); @@ -1735,9 +1757,7 @@ public class Vala.GIdlParser : CodeVisitor { } else if (nv[0] == "type_arguments") { var type_args = eval (nv[1]).split (","); foreach (string type_arg in type_args) { - var arg_type = new UnresolvedType.from_symbol (new UnresolvedSymbol (null, type_arg)); - arg_type.value_owned = true; - param_type.add_type_argument (arg_type); + param_type.add_type_argument (get_type_from_string (type_arg)); } } } @@ -1909,9 +1929,7 @@ public class Vala.GIdlParser : CodeVisitor { } else if (nv[0] == "type_arguments") { var type_args = eval (nv[1]).split (","); foreach (string type_arg in type_args) { - var arg_type = new UnresolvedType.from_symbol (new UnresolvedSymbol (null, type_arg)); - arg_type.value_owned = true; - prop.property_type.add_type_argument (arg_type); + prop.property_type.add_type_argument (get_type_from_string (type_arg)); } } else if (nv[0] == "accessor_method") { if (eval (nv[1]) == "0") { @@ -2005,9 +2023,7 @@ public class Vala.GIdlParser : CodeVisitor { } else if (nv[0] == "type_arguments") { var type_args = eval (nv[1]).split (","); foreach (string type_arg in type_args) { - var arg_type = new UnresolvedType.from_symbol (new UnresolvedSymbol (null, type_arg)); - arg_type.value_owned = true; - type.add_type_argument (arg_type); + type.add_type_argument (get_type_from_string (type_arg)); } } else if (nv[0] == "cheader_filename") { cheader_filename = eval (nv[1]); @@ -2097,8 +2113,46 @@ public class Vala.GIdlParser : CodeVisitor { if (attributes == null) { return null; } - - return attributes.split (" "); + + GLib.SList<string> attr_list = new GLib.SList<string> (); + var attr = new GLib.StringBuilder.sized (attributes.size ()); + var attributes_len = attributes.len (); + unowned string remaining = attributes; + bool quoted = false, escaped = false; + for (int b = 0 ; b < attributes_len ; b++) { + unichar c = remaining.get_char (); + + if (escaped) { + escaped = false; + attr.append_unichar (c); + } else { + if (c == '"') { + attr.append_unichar (c); + quoted = !quoted; + } else if (c == '\\') { + escaped = true; + } else if (!quoted && (c == ' ')) { + attr_list.prepend (attr.str); + attr.truncate (0); + } else { + attr.append_unichar (c); + } + } + + remaining = remaining.offset (1); + } + + if (attr.len > 0) { + attr_list.prepend (attr.str); + } + + var attrs = new string[attr_list.length ()]; + unowned GLib.SList<string>? attr_i = attr_list; + for (int a = 0 ; a < attrs.length ; a++, attr_i = attr_i.next) { + attrs[(attrs.length - 1) - a] = attr_i.data; + } + + return attrs; } private string eval (string s) {
1c52b6551b63053b261f4ac821093a8a203de596
hadoop
YARN-2705. Fixed bugs in ResourceManager node-label- manager that were causing test-failures: added a dummy in-memory- labels-manager. Contributed by Wangda Tan.--(cherry picked from commit e9c66e8fd2ccb658db2848e1ab911f1502de4de5)-
c
https://github.com/apache/hadoop
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 0300b2e6a359b..63e0e6c94bda7 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -570,6 +570,10 @@ Release 2.6.0 - UNRELEASED YARN-2699. Fixed a bug in CommonNodeLabelsManager that caused tests to fail when using ephemeral ports on NodeIDs. (Wangda Tan via vinodkv) + YARN-2705. Fixed bugs in ResourceManager node-label manager that were causing + test-failures: added a dummy in-memory labels-manager. (Wangda Tan via + vinodkv) + BREAKDOWN OF YARN-1051 SUBTASKS AND RELATED JIRAS YARN-1707. Introduce APIs to add/remove/resize queues in the diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java index a5e746451e7e8..03a1f6011e0e5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java @@ -1457,10 +1457,16 @@ public class YarnConfiguration extends Configuration { public static final String NODE_LABELS_PREFIX = YARN_PREFIX + "node-labels."; + /** + * Class for RMNodeLabelsManager Please note this value should be consistent + * in client nodes and RM node(s) + */ + public static final String RM_NODE_LABELS_MANAGER_CLASS = NODE_LABELS_PREFIX + + "manager-class"; + /** URI for NodeLabelManager */ - public static final String FS_NODE_LABELS_STORE_URI = NODE_LABELS_PREFIX - + "fs-store.uri"; - public static final String DEFAULT_FS_NODE_LABELS_STORE_URI = "file:///tmp/"; + public static final String FS_NODE_LABELS_STORE_ROOT_DIR = NODE_LABELS_PREFIX + + "fs-store.root-dir"; public static final String FS_NODE_LABELS_STORE_RETRY_POLICY_SPEC = NODE_LABELS_PREFIX + "fs-store.retry-policy-spec"; public static final String DEFAULT_FS_NODE_LABELS_STORE_RETRY_POLICY_SPEC = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java index 8bb88f27c6539..d68503555f24d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/CommonNodeLabelsManager.java @@ -220,9 +220,11 @@ protected void serviceStart() throws Exception { // service init, we don't want to trigger any event handling at that time. initDispatcher(getConfig()); - dispatcher.register(NodeLabelsStoreEventType.class, - new ForwardingEventHandler()); - + if (null != dispatcher) { + dispatcher.register(NodeLabelsStoreEventType.class, + new ForwardingEventHandler()); + } + startDispatcher(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java index 2778c742a2d1a..6e685ee3301d6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/nodelabels/FileSystemNodeLabelsStore.java @@ -32,6 +32,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.LocalFileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.AddToClusterNodeLabelsRequestProto; @@ -54,7 +55,7 @@ public FileSystemNodeLabelsStore(CommonNodeLabelsManager mgr) { protected static final Log LOG = LogFactory.getLog(FileSystemNodeLabelsStore.class); - protected static final String ROOT_DIR_NAME = "FSNodeLabelManagerRoot"; + protected static final String DEFAULT_DIR_NAME = "node-labels"; protected static final String MIRROR_FILENAME = "nodelabel.mirror"; protected static final String EDITLOG_FILENAME = "nodelabel.editlog"; @@ -63,22 +64,27 @@ protected enum SerializedLogType { } Path fsWorkingPath; - Path rootDirPath; FileSystem fs; FSDataOutputStream editlogOs; Path editLogPath; + + private String getDefaultFSNodeLabelsRootDir() throws IOException { + // default is in local: /tmp/hadoop-yarn-${user}/node-labels/ + return "file:///tmp/hadoop-yarn-" + + UserGroupInformation.getCurrentUser().getShortUserName() + "/" + + DEFAULT_DIR_NAME; + } @Override public void init(Configuration conf) throws Exception { fsWorkingPath = - new Path(conf.get(YarnConfiguration.FS_NODE_LABELS_STORE_URI, - YarnConfiguration.DEFAULT_FS_NODE_LABELS_STORE_URI)); - rootDirPath = new Path(fsWorkingPath, ROOT_DIR_NAME); + new Path(conf.get(YarnConfiguration.FS_NODE_LABELS_STORE_ROOT_DIR, + getDefaultFSNodeLabelsRootDir())); setFileSystem(conf); // mkdir of root dir path - fs.mkdirs(rootDirPath); + fs.mkdirs(fsWorkingPath); } @Override @@ -159,8 +165,8 @@ public void recover() throws IOException { */ // Open mirror from serialized file - Path mirrorPath = new Path(rootDirPath, MIRROR_FILENAME); - Path oldMirrorPath = new Path(rootDirPath, MIRROR_FILENAME + ".old"); + Path mirrorPath = new Path(fsWorkingPath, MIRROR_FILENAME); + Path oldMirrorPath = new Path(fsWorkingPath, MIRROR_FILENAME + ".old"); FSDataInputStream is = null; if (fs.exists(mirrorPath)) { @@ -183,7 +189,7 @@ public void recover() throws IOException { } // Open and process editlog - editLogPath = new Path(rootDirPath, EDITLOG_FILENAME); + editLogPath = new Path(fsWorkingPath, EDITLOG_FILENAME); if (fs.exists(editLogPath)) { is = fs.open(editLogPath); @@ -224,7 +230,7 @@ public void recover() throws IOException { } // Serialize current mirror to mirror.writing - Path writingMirrorPath = new Path(rootDirPath, MIRROR_FILENAME + ".writing"); + Path writingMirrorPath = new Path(fsWorkingPath, MIRROR_FILENAME + ".writing"); FSDataOutputStream os = fs.create(writingMirrorPath, true); ((AddToClusterNodeLabelsRequestPBImpl) AddToClusterNodeLabelsRequestPBImpl .newInstance(mgr.getClusterNodeLabels())).getProto().writeDelimitedTo(os); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java index a7546cb70406f..45a2d8d32f214 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/nodelabels/TestFileSystemNodeLabelsStore.java @@ -67,7 +67,7 @@ public void before() throws IOException { tempDir.delete(); tempDir.mkdirs(); tempDir.deleteOnExit(); - conf.set(YarnConfiguration.FS_NODE_LABELS_STORE_URI, + conf.set(YarnConfiguration.FS_NODE_LABELS_STORE_ROOT_DIR, tempDir.getAbsolutePath()); mgr.init(conf); mgr.start(); @@ -75,7 +75,7 @@ public void before() throws IOException { @After public void after() throws IOException { - getStore().fs.delete(getStore().rootDirPath, true); + getStore().fs.delete(getStore().fsWorkingPath, true); mgr.stop(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java index bcf7a5488452a..51ed2b1a9b9e3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ResourceManager.java @@ -67,6 +67,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher; import org.apache.hadoop.yarn.server.resourcemanager.monitor.SchedulingEditPolicy; import org.apache.hadoop.yarn.server.resourcemanager.monitor.SchedulingMonitor; +import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.MemoryRMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.recovery.NullRMStateStore; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore; @@ -321,8 +322,12 @@ protected AMLivelinessMonitor createAMLivelinessMonitor() { return new AMLivelinessMonitor(this.rmDispatcher); } - protected RMNodeLabelsManager createNodeLabelManager() { - return new RMNodeLabelsManager(); + protected RMNodeLabelsManager createNodeLabelManager() + throws InstantiationException, IllegalAccessException { + Class<? extends RMNodeLabelsManager> nlmCls = + conf.getClass(YarnConfiguration.RM_NODE_LABELS_MANAGER_CLASS, + MemoryRMNodeLabelsManager.class, RMNodeLabelsManager.class); + return nlmCls.newInstance(); } protected DelegationTokenRenewer createDelegationTokenRenewer() { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/DummyRMNodeLabelsManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/MemoryRMNodeLabelsManager.java similarity index 93% rename from hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/DummyRMNodeLabelsManager.java rename to hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/MemoryRMNodeLabelsManager.java index 14bd99984c5b9..89053ca9baa4a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/DummyRMNodeLabelsManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/MemoryRMNodeLabelsManager.java @@ -25,10 +25,9 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.yarn.api.records.NodeId; -import org.apache.hadoop.yarn.event.InlineDispatcher; import org.apache.hadoop.yarn.nodelabels.NodeLabelsStore; -public class DummyRMNodeLabelsManager extends RMNodeLabelsManager { +public class MemoryRMNodeLabelsManager extends RMNodeLabelsManager { Map<NodeId, Set<String>> lastNodeToLabels = null; Collection<String> lastAddedlabels = null; Collection<String> lastRemovedlabels = null; @@ -68,7 +67,7 @@ public void close() throws IOException { @Override protected void initDispatcher(Configuration conf) { - super.dispatcher = new InlineDispatcher(); + super.dispatcher = null; } @Override diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java index 0c70f68c71393..9d0ac2739bc66 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/MockRM.java @@ -59,7 +59,7 @@ import org.apache.hadoop.yarn.server.api.protocolrecords.NMContainerStatus; import org.apache.hadoop.yarn.server.resourcemanager.amlauncher.AMLauncherEvent; import org.apache.hadoop.yarn.server.resourcemanager.amlauncher.ApplicationMasterLauncher; -import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.DummyRMNodeLabelsManager; +import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.MemoryRMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; @@ -115,7 +115,7 @@ public MockRM(Configuration conf, RMStateStore store) { @Override protected RMNodeLabelsManager createNodeLabelManager() { - RMNodeLabelsManager mgr = new DummyRMNodeLabelsManager(); + RMNodeLabelsManager mgr = new MemoryRMNodeLabelsManager(); mgr.init(getConfig()); return mgr; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/TestRMNodeLabelsManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/TestRMNodeLabelsManager.java index 1fbe96869fb2d..0ea745692b83b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/TestRMNodeLabelsManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/nodelabels/TestRMNodeLabelsManager.java @@ -42,11 +42,11 @@ public class TestRMNodeLabelsManager extends NodeLabelTestBase { private final Resource SMALL_RESOURCE = Resource.newInstance(100, 0); private final Resource LARGE_NODE = Resource.newInstance(1000, 0); - DummyRMNodeLabelsManager mgr = null; + MemoryRMNodeLabelsManager mgr = null; @Before public void before() { - mgr = new DummyRMNodeLabelsManager(); + mgr = new MemoryRMNodeLabelsManager(); mgr.init(new Configuration()); mgr.start(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java index e15c87d00e03f..98dc673da2563 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java @@ -84,7 +84,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.Task; import org.apache.hadoop.yarn.server.resourcemanager.TestAMAuthorization.MockRMWithAMS; import org.apache.hadoop.yarn.server.resourcemanager.TestAMAuthorization.MyContainerManager; -import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.DummyRMNodeLabelsManager; +import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.MemoryRMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics; @@ -154,7 +154,7 @@ public void setUp() throws Exception { resourceManager = new ResourceManager() { @Override protected RMNodeLabelsManager createNodeLabelManager() { - RMNodeLabelsManager mgr = new DummyRMNodeLabelsManager(); + RMNodeLabelsManager mgr = new MemoryRMNodeLabelsManager(); mgr.init(getConfig()); return mgr; } @@ -1485,7 +1485,7 @@ public void testMoveAppViolateQueueState() throws Exception { resourceManager = new ResourceManager() { @Override protected RMNodeLabelsManager createNodeLabelManager() { - RMNodeLabelsManager mgr = new DummyRMNodeLabelsManager(); + RMNodeLabelsManager mgr = new MemoryRMNodeLabelsManager(); mgr.init(getConfig()); return mgr; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java index b84717bbc328c..b90df8ec5a769 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java @@ -45,7 +45,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMSecretManagerService; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.TestFifoScheduler; -import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.DummyRMNodeLabelsManager; +import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.MemoryRMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt; @@ -81,7 +81,7 @@ public void setUp() throws Exception { conf = new YarnConfiguration(); conf.setClass(YarnConfiguration.RM_SCHEDULER, CapacityScheduler.class, ResourceScheduler.class); - mgr = new DummyRMNodeLabelsManager(); + mgr = new MemoryRMNodeLabelsManager(); mgr.init(conf); } @@ -446,7 +446,7 @@ private Configuration getComplexConfigurationWithQueueLabels( @Test(timeout = 300000) public void testContainerAllocationWithSingleUserLimits() throws Exception { - final RMNodeLabelsManager mgr = new DummyRMNodeLabelsManager(); + final RMNodeLabelsManager mgr = new MemoryRMNodeLabelsManager(); mgr.init(conf); // set node -> label diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java index 7e6165274b28a..abc701db192fb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebApp.java @@ -39,7 +39,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.RMContextImpl; import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; import org.apache.hadoop.yarn.server.resourcemanager.applicationsmanager.MockAsm; -import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.DummyRMNodeLabelsManager; +import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.MemoryRMNodeLabelsManager; import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp; import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode; import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; @@ -179,7 +179,7 @@ public ConcurrentMap<NodeId, RMNode> getRMNodes() { return nodesMap; } }; - rmContext.setNodeLabelManager(new DummyRMNodeLabelsManager()); + rmContext.setNodeLabelManager(new MemoryRMNodeLabelsManager()); return rmContext; } @@ -211,7 +211,7 @@ public static CapacityScheduler mockCapacityScheduler() throws IOException { null, new RMContainerTokenSecretManager(conf), new NMTokenSecretManagerInRM(conf), new ClientToAMTokenSecretManagerInRM(), null); - rmContext.setNodeLabelManager(new DummyRMNodeLabelsManager()); + rmContext.setNodeLabelManager(new MemoryRMNodeLabelsManager()); cs.setRMContext(rmContext); cs.init(conf); return cs;
1135c8ce7a43dcbb05c678e0f032d6b646104066
kotlin
KT-737 compareTo() intrinsic--
c
https://github.com/JetBrains/kotlin
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java index c51d21d780190..5649fe11f01ad 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -320,7 +320,8 @@ else if (functionParent instanceof ClassDescriptor) { ClassDescriptor containingClass = (ClassDescriptor) functionParent; boolean isInterface = CodegenUtil.isInterface(containingClass); OwnerKind kind1 = isInterface && superCall ? OwnerKind.TRAIT_IMPL : OwnerKind.IMPLEMENTATION; - owner = mapType(containingClass.getDefaultType(), kind1).getInternalName(); + Type type = mapType(containingClass.getDefaultType(), kind1); + owner = type.getInternalName(); invokeOpcode = isInterface ? (superCall ? Opcodes.INVOKESTATIC : Opcodes.INVOKEINTERFACE) : (superCall ? Opcodes.INVOKESPECIAL : Opcodes.INVOKEVIRTUAL); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/CompareTo.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/CompareTo.java new file mode 100644 index 0000000000000..991d84c12317e --- /dev/null +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/CompareTo.java @@ -0,0 +1,45 @@ +package org.jetbrains.jet.codegen.intrinsics; + +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.codegen.ExpressionCodegen; +import org.jetbrains.jet.codegen.JetTypeMapper; +import org.jetbrains.jet.codegen.StackValue; +import org.jetbrains.jet.lang.psi.JetExpression; +import org.objectweb.asm.Type; +import org.objectweb.asm.commons.InstructionAdapter; + +import java.util.List; + +/** + * @author alex.tkachman + */ +public class CompareTo implements IntrinsicMethod { + @Override + public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, @Nullable PsiElement element, @Nullable List<JetExpression> arguments, StackValue receiver) { + assert arguments != null; + receiver.put(receiver.type, v); + codegen.gen(arguments.get(0), receiver.type); + if(receiver.type == Type.BYTE_TYPE || receiver.type == Type.SHORT_TYPE || receiver.type == Type.CHAR_TYPE) + v.sub(Type.INT_TYPE); + else if(receiver.type == Type.INT_TYPE) { + v.invokestatic("jet/runtime/Intrinsics", "compare", "(II)I"); + } + else if(receiver.type == Type.BOOLEAN_TYPE) { + v.invokestatic("jet/runtime/Intrinsics", "compare", "(ZZ)I"); + } + else if(receiver.type == Type.LONG_TYPE) { + v.invokestatic("jet/runtime/Intrinsics", "compare", "(JJ)I"); + } + else if(receiver.type == Type.FLOAT_TYPE) { + v.invokestatic("java/lang/Float", "compare", "(FF)I"); + } + else if(receiver.type == Type.DOUBLE_TYPE) { + v.invokestatic("java/lang/Double", "compare", "(DD)I"); + } + else { + throw new UnsupportedOperationException(); + } + return StackValue.onStack(Type.INT_TYPE); + } +} diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java index 33e107c2143cb..6ccff8d02b34a 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java @@ -97,6 +97,9 @@ public IntrinsicMethods(Project project, JetStandardLibrary stdlib) { declareIntrinsicFunction("FloatIterator", "next", 0, ITERATOR_NEXT); declareIntrinsicFunction("DoubleIterator", "next", 0, ITERATOR_NEXT); + for (String type : PRIMITIVE_NUMBER_TYPES) { + declareIntrinsicFunction(type, "compareTo", 1, new CompareTo()); + } // declareIntrinsicFunction("Any", "equals", 1, new Equals()); // declareIntrinsicStringMethods(); diff --git a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java index bb38c2d8e1be3..6dfec5e3e79bb 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java @@ -315,6 +315,12 @@ public void testSafeNullable () throws Exception { assertTrue(generateToText().contains("IFNULL")); } + public void testKt737() throws Exception { + loadText("fun box() = if(3.compareTo(2) != 1) \"fail\" else if(5.byt.compareTo(10.lng) >= 0) \"fail\" else \"OK\""); + System.out.println(generateToText()); + assertEquals("OK", blackBox()); + } + public void testKt665() throws Exception { loadText("fun f(x: Long, zzz: Long = 1): Long\n" + "{\n" + diff --git a/stdlib/src/jet/runtime/Intrinsics.java b/stdlib/src/jet/runtime/Intrinsics.java index d162e3634d644..19488b98ba24e 100644 --- a/stdlib/src/jet/runtime/Intrinsics.java +++ b/stdlib/src/jet/runtime/Intrinsics.java @@ -17,6 +17,18 @@ public static void throwNpe() { throw new JetNullPointerException(); } + public static int compare(long thisVal, long anotherVal) { + return (thisVal<anotherVal ? -1 : (thisVal==anotherVal ? 0 : 1)); + } + + public static int compare(int thisVal, int anotherVal) { + return (thisVal<anotherVal ? -1 : (thisVal==anotherVal ? 0 : 1)); + } + + public static int compare(boolean thisVal, boolean anotherVal) { + return (thisVal == anotherVal ? 0 : (anotherVal ? 1 : -1)); + } + private static Throwable sanitizeStackTrace(Throwable throwable) { StackTraceElement[] stackTrace = throwable.getStackTrace(); ArrayList<StackTraceElement> list = new ArrayList<StackTraceElement>();
512b4f8b9423e962db00dd90b7a89dbf43c6fe9a
tapiji
updated licenses
p
https://github.com/tapiji/tapiji
diff --git a/at.ac.tuwien.inso.eclipse.i18n.java/build.properties b/at.ac.tuwien.inso.eclipse.i18n.java/build.properties index 6f20375d..1fcd8783 100644 --- a/at.ac.tuwien.inso.eclipse.i18n.java/build.properties +++ b/at.ac.tuwien.inso.eclipse.i18n.java/build.properties @@ -2,4 +2,9 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - plugin.xml + plugin.xml,\ + epl-v10.html +src.includes = src/,\ + plugin.xml,\ + epl-v10.html,\ + META-INF/ diff --git a/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/build.properties b/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/build.properties index 82ab19c6..1fe28114 100644 --- a/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/build.properties +++ b/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/build.properties @@ -1 +1,4 @@ -bin.includes = feature.xml +bin.includes = feature.xml,\ + epl-v10.html +src.includes = epl-v10.html,\ + feature.xml diff --git a/at.ac.tuwien.inso.eclipse.i18n.jsf/build.properties b/at.ac.tuwien.inso.eclipse.i18n.jsf/build.properties index 6f20375d..1fcd8783 100644 --- a/at.ac.tuwien.inso.eclipse.i18n.jsf/build.properties +++ b/at.ac.tuwien.inso.eclipse.i18n.jsf/build.properties @@ -2,4 +2,9 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - plugin.xml + plugin.xml,\ + epl-v10.html +src.includes = src/,\ + plugin.xml,\ + epl-v10.html,\ + META-INF/ diff --git a/at.ac.tuwien.inso.eclipse.i18n/build.properties b/at.ac.tuwien.inso.eclipse.i18n/build.properties index d3d7c2c2..498c204b 100644 --- a/at.ac.tuwien.inso.eclipse.i18n/build.properties +++ b/at.ac.tuwien.inso.eclipse.i18n/build.properties @@ -11,7 +11,8 @@ bin.includes = plugin.xml,\ about.properties,\ TapiJI.png,\ Splash.bmp,\ - TapiJI.gif + TapiJI.gif,\ + epl-v10.html bin.excludes = icons/original/,\ icons/photoshop/ src.excludes = icons/original/,\ @@ -26,4 +27,6 @@ src.includes = src/,\ META-INF/,\ TapiJI.png,\ Splash.bmp,\ - TapiJI.gif + TapiJI.gif,\ + plugin.xml,\ + epl-v10.html diff --git a/at.ac.tuwien.inso.eclipse.tapiji/build.properties b/at.ac.tuwien.inso.eclipse.tapiji/build.properties index 1c55c57f..40daa89e 100644 --- a/at.ac.tuwien.inso.eclipse.tapiji/build.properties +++ b/at.ac.tuwien.inso.eclipse.tapiji/build.properties @@ -4,10 +4,12 @@ bin.includes = plugin.xml,\ META-INF/,\ .,\ icons/,\ - splash.bmp + splash.bmp,\ + epl-v10.html src.includes = splash.bmp,\ icons/,\ bin/,\ src/,\ - META-INF/ + META-INF/,\ + epl-v10.html diff --git a/at.ac.tuwien.inso.eclipse.tapiji/epl-v10.html b/at.ac.tuwien.inso.eclipse.tapiji/epl-v10.html new file mode 100644 index 00000000..ed4b1966 --- /dev/null +++ b/at.ac.tuwien.inso.eclipse.tapiji/epl-v10.html @@ -0,0 +1,328 @@ +<html xmlns:o="urn:schemas-microsoft-com:office:office" +xmlns:w="urn:schemas-microsoft-com:office:word" +xmlns="http://www.w3.org/TR/REC-html40"> + +<head> +<meta http-equiv=Content-Type content="text/html; charset=windows-1252"> +<meta name=ProgId content=Word.Document> +<meta name=Generator content="Microsoft Word 9"> +<meta name=Originator content="Microsoft Word 9"> +<link rel=File-List +href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml"> +<title>Eclipse Public License - Version 1.0</title> +<!--[if gte mso 9]><xml> + <o:DocumentProperties> + <o:Revision>2</o:Revision> + <o:TotalTime>3</o:TotalTime> + <o:Created>2004-03-05T23:03:00Z</o:Created> + <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved> + <o:Pages>4</o:Pages> + <o:Words>1626</o:Words> + <o:Characters>9270</o:Characters> + <o:Lines>77</o:Lines> + <o:Paragraphs>18</o:Paragraphs> + <o:CharactersWithSpaces>11384</o:CharactersWithSpaces> + <o:Version>9.4402</o:Version> + </o:DocumentProperties> +</xml><![endif]--><!--[if gte mso 9]><xml> + <w:WordDocument> + <w:TrackRevisions/> + </w:WordDocument> +</xml><![endif]--> +<style> +<!-- + /* Font Definitions */ +@font-face + {font-family:Tahoma; + panose-1:2 11 6 4 3 5 4 4 2 4; + mso-font-charset:0; + mso-generic-font-family:swiss; + mso-font-pitch:variable; + mso-font-signature:553679495 -2147483648 8 0 66047 0;} + /* Style Definitions */ +p.MsoNormal, li.MsoNormal, div.MsoNormal + {mso-style-parent:""; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p + {margin-right:0in; + mso-margin-top-alt:auto; + mso-margin-bottom-alt:auto; + margin-left:0in; + mso-pagination:widow-orphan; + font-size:12.0pt; + font-family:"Times New Roman"; + mso-fareast-font-family:"Times New Roman";} +p.BalloonText, li.BalloonText, div.BalloonText + {mso-style-name:"Balloon Text"; + margin:0in; + margin-bottom:.0001pt; + mso-pagination:widow-orphan; + font-size:8.0pt; + font-family:Tahoma; + mso-fareast-font-family:"Times New Roman";} +@page Section1 + {size:8.5in 11.0in; + margin:1.0in 1.25in 1.0in 1.25in; + mso-header-margin:.5in; + mso-footer-margin:.5in; + mso-paper-source:0;} +div.Section1 + {page:Section1;} +--> +</style> +</head> + +<body lang=EN-US style='tab-interval:.5in'> + +<div class=Section1> + +<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b> +</p> + +<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER +THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, +REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE +OF THIS AGREEMENT.</span> </p> + +<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p> + +<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +in the case of the initial Contributor, the initial code and documentation +distributed under this Agreement, and<br clear=left> +b) in the case of each subsequent Contributor:</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i) +changes to the Program, and</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii) +additions to the Program;</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where +such changes and/or additions to the Program originate from and are distributed +by that particular Contributor. A Contribution 'originates' from a Contributor +if it was added to the Program by such Contributor itself or anyone acting on +such Contributor's behalf. Contributions do not include additions to the +Program which: (i) are separate modules of software distributed in conjunction +with the Program under their own license agreement, and (ii) are not derivative +works of the Program. </span></p> + +<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or +entity that distributes the Program.</span> </p> + +<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent +claims licensable by a Contributor which are necessarily infringed by the use +or sale of its Contribution alone or when combined with the Program. </span></p> + +<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions +distributed in accordance with this Agreement.</span> </p> + +<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who +receives the Program under this Agreement, including all Contributors.</span> </p> + +<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +Subject to the terms of this Agreement, each Contributor hereby grants Recipient +a non-exclusive, worldwide, royalty-free copyright license to<span +style='color:red'> </span>reproduce, prepare derivative works of, publicly +display, publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and object code +form.</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) +Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free +patent license under Licensed Patents to make, use, sell, offer to sell, import +and otherwise transfer the Contribution of such Contributor, if any, in source +code and object code form. This patent license shall apply to the combination +of the Contribution and the Program if, at the time the Contribution is added +by the Contributor, such addition of the Contribution causes such combination +to be covered by the Licensed Patents. The patent license shall not apply to +any other combinations which include the Contribution. No hardware per se is +licensed hereunder. </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c) +Recipient understands that although each Contributor grants the licenses to its +Contributions set forth herein, no assurances are provided by any Contributor +that the Program does not infringe the patent or other intellectual property +rights of any other entity. Each Contributor disclaims any liability to Recipient +for claims brought by any other entity based on infringement of intellectual +property rights or otherwise. As a condition to exercising the rights and +licenses granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For example, +if a third party patent license is required to allow Recipient to distribute +the Program, it is Recipient's responsibility to acquire that license before +distributing the Program.</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d) +Each Contributor represents that to its knowledge it has sufficient copyright +rights in its Contribution, if any, to grant the copyright license set forth in +this Agreement. </span></p> + +<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p> + +<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the +Program in object code form under its own license agreement, provided that:</span> +</p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +it complies with the terms and conditions of this Agreement; and</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) +its license agreement:</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i) +effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title +and non-infringement, and implied warranties or conditions of merchantability +and fitness for a particular purpose; </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii) +effectively excludes on behalf of all Contributors all liability for damages, +including direct, indirect, special, incidental and consequential damages, such +as lost profits; </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii) +states that any provisions which differ from this Agreement are offered by that +Contributor alone and not by any other party; and</span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv) +states that source code for the Program is available from such Contributor, and +informs licensees how to obtain it in a reasonable manner on or through a +medium customarily used for software exchange.<span style='color:blue'> </span></span></p> + +<p><span style='font-size:10.0pt'>When the Program is made available in source +code form:</span> </p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a) +it must be made available under this Agreement; and </span></p> + +<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a +copy of this Agreement must be included with each copy of the Program. </span></p> + +<p><span style='font-size:10.0pt'>Contributors may not remove or alter any +copyright notices contained within the Program. </span></p> + +<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the +originator of its Contribution, if any, in a manner that reasonably allows +subsequent Recipients to identify the originator of the Contribution. </span></p> + +<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p> + +<p><span style='font-size:10.0pt'>Commercial distributors of software may +accept certain responsibilities with respect to end users, business partners +and the like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a commercial +product offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes the +Program in a commercial product offering, such Contributor (&quot;Commercial +Contributor&quot;) hereby agrees to defend and indemnify every other +Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and +costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other +legal actions brought by a third party against the Indemnified Contributor to +the extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor +to control, and cooperate with the Commercial Contributor in, the defense and +any related settlement negotiations. The Indemnified Contributor may participate +in any such claim at its own expense.</span> </p> + +<p><span style='font-size:10.0pt'>For example, a Contributor might include the +Program in a commercial product offering, Product X. That Contributor is then a +Commercial Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance claims and +warranties are such Commercial Contributor's responsibility alone. Under this +section, the Commercial Contributor would have to defend claims against the +other Contributors related to those performance claims and warranties, and if a +court requires any other Contributor to pay any damages as a result, the +Commercial Contributor must pay those damages.</span> </p> + +<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p> + +<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, +WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and distributing the +Program and assumes all risks associated with its exercise of rights under this +Agreement , including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs or +equipment, and unavailability or interruption of operations. </span></p> + +<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p> + +<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS +AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF +THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGES.</span> </p> + +<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p> + +<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid +or unenforceable under applicable law, it shall not affect the validity or +enforceability of the remainder of the terms of this Agreement, and without +further action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable.</span> </p> + +<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation +against any entity (including a cross-claim or counterclaim in a lawsuit) +alleging that the Program itself (excluding combinations of the Program with +other software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of the date +such litigation is filed. </span></p> + +<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement +shall terminate if it fails to comply with any of the material terms or +conditions of this Agreement and does not cure such failure in a reasonable +period of time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use and +distribution of the Program as soon as reasonably practicable. However, +Recipient's obligations under this Agreement and any licenses granted by +Recipient relating to the Program shall continue and survive. </span></p> + +<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute +copies of this Agreement, but in order to avoid inconsistency the Agreement is +copyrighted and may only be modified in the following manner. The Agreement +Steward reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement Steward has +the right to modify this Agreement. The Eclipse Foundation is the initial +Agreement Steward. The Eclipse Foundation may assign the responsibility to +serve as the Agreement Steward to a suitable separate entity. Each new version +of the Agreement will be given a distinguishing version number. The Program +(including Contributions) may always be distributed subject to the version of +the Agreement under which it was received. In addition, after a new version of +the Agreement is published, Contributor may elect to distribute the Program +(including its Contributions) under the new version. Except as expressly stated +in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to +the intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved.</span> </p> + +<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the +State of New York and the intellectual property laws of the United States of +America. No party to this Agreement will bring a legal action under this +Agreement more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation.</span> </p> + +<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p> + +</div> + +</body> + +</html> \ No newline at end of file diff --git a/at.ac.tuwien.inso.eclpise.i18n.feature/build.properties b/at.ac.tuwien.inso.eclpise.i18n.feature/build.properties index 82ab19c6..1fe28114 100644 --- a/at.ac.tuwien.inso.eclpise.i18n.feature/build.properties +++ b/at.ac.tuwien.inso.eclpise.i18n.feature/build.properties @@ -1 +1,4 @@ -bin.includes = feature.xml +bin.includes = feature.xml,\ + epl-v10.html +src.includes = epl-v10.html,\ + feature.xml
61edb8bd082810d16bb25ac4a526df4ac036f3fa
restlet-framework-java
Fixed "not found" status for Options requests.--
c
https://github.com/restlet/restlet-framework-java
diff --git a/modules/org.restlet.ext.wadl_1.0/src/org/restlet/ext/wadl/WadlApplication.java b/modules/org.restlet.ext.wadl_1.0/src/org/restlet/ext/wadl/WadlApplication.java index 924edf6512..c1242bc579 100644 --- a/modules/org.restlet.ext.wadl_1.0/src/org/restlet/ext/wadl/WadlApplication.java +++ b/modules/org.restlet.ext.wadl_1.0/src/org/restlet/ext/wadl/WadlApplication.java @@ -531,7 +531,10 @@ private ResourceInfo getResourceInfo(Restlet restlet, String path, Request request, Response response) { ResourceInfo result = null; - if (restlet instanceof Finder) { + if (restlet instanceof WadlDescribable) { + result = ((WadlDescribable) restlet).getResourceInfo(); + result.setPath(path); + } else if (restlet instanceof Finder) { result = getResourceInfo((Finder) restlet, path, request, response); } else if (restlet instanceof Router) { result = new ResourceInfo(); @@ -541,7 +544,6 @@ private ResourceInfo getResourceInfo(Restlet restlet, String path, } else if (restlet instanceof Filter) { result = getResourceInfo((Filter) restlet, path, request, response); } - return result; } @@ -691,6 +693,9 @@ public void handle(Request request, Response response) { // Returns a WADL representation of the application. response.setEntity(wadlRepresent(request, response)); + if (response.isEntityAvailable()) { + response.setStatus(Status.SUCCESS_OK); + } } }
8a07f772e2d36b759f4d5ab6f213fbb0869a1766
orientdb
Fixed issue with inner class and Object Database- interface--
c
https://github.com/orientechnologies/orientdb
diff --git a/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntityEnhancer.java b/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntityEnhancer.java index f4e5e89df7d..db4864a47d8 100644 --- a/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntityEnhancer.java +++ b/object/src/main/java/com/orientechnologies/orient/object/enhancement/OObjectEntityEnhancer.java @@ -49,281 +49,286 @@ */ public class OObjectEntityEnhancer { - private static final OObjectEntityEnhancer instance = new OObjectEntityEnhancer(); + private static final OObjectEntityEnhancer instance = new OObjectEntityEnhancer(); - public static final String ENHANCER_CLASS_PREFIX = "orientdb_"; + public static final String ENHANCER_CLASS_PREFIX = "orientdb_"; - public OObjectEntityEnhancer() { - } + public OObjectEntityEnhancer() { + } - @SuppressWarnings("unchecked") - public <T> T getProxiedInstance(final String iClass, final OEntityManager entityManager, final ODocument doc, Object... iArgs) { - final Class<T> clazz = (Class<T>) entityManager.getEntityClass(iClass); - return getProxiedInstance(clazz, doc, iArgs); - } + @SuppressWarnings("unchecked") + public <T> T getProxiedInstance(final String iClass, final OEntityManager entityManager, final ODocument doc, Object... iArgs) { + final Class<T> clazz = (Class<T>) entityManager.getEntityClass(iClass); + return getProxiedInstance(clazz, doc, iArgs); + } - @SuppressWarnings("unchecked") - public <T> T getProxiedInstance(final String iClass, final Object iEnclosingInstance, final OEntityManager entityManager, - final ODocument doc, Object... iArgs) { - final Class<T> clazz = (Class<T>) entityManager.getEntityClass(iClass); - return getProxiedInstance(clazz, iEnclosingInstance, doc, iArgs); - } + @SuppressWarnings("unchecked") + public <T> T getProxiedInstance(final String iClass, final Object iEnclosingInstance, final OEntityManager entityManager, + final ODocument doc, Object... iArgs) { + final Class<T> clazz = (Class<T>) entityManager.getEntityClass(iClass); + return getProxiedInstance(clazz, iEnclosingInstance, doc, iArgs); + } - public <T> T getProxiedInstance(final Class<T> iClass, final ODocument doc, Object... iArgs) { - return getProxiedInstance(iClass, null, doc, iArgs); - } + public <T> T getProxiedInstance(final Class<T> iClass, final ODocument doc, Object... iArgs) { + return getProxiedInstance(iClass, null, doc, iArgs); + } - @SuppressWarnings("unchecked") - public <T> T getProxiedInstance(final Class<T> iClass, Object iEnclosingInstance, final ODocument doc, Object... iArgs) { - if (iClass == null) { - throw new OSerializationException("Type " + doc.getClassName() - + " cannot be serialized because is not part of registered entities. To fix this error register this class"); - } - final Class<T> c; - boolean isInnerClass = iClass.getEnclosingClass() != null; - if (Proxy.class.isAssignableFrom(iClass)) { - c = iClass; - } else { - ProxyFactory f = new ProxyFactory(); - f.setSuperclass(iClass); - f.setFilter(new MethodFilter() { - public boolean isHandled(Method m) { - final String methodName = m.getName(); - try { - return (isSetterMethod(methodName, m) || isGetterMethod(methodName, m) || methodName.equals("equals") || methodName - .equals("hashCode")); - } catch (NoSuchFieldException nsfe) { - OLogManager.instance().warn(this, "Error handling the method %s in class %s", nsfe, m.getName(), iClass.getName()); - return false; - } catch (SecurityException se) { - OLogManager.instance().warn(this, "", se, m.getName(), iClass.getName()); - return false; - } - } - }); - c = f.createClass(); - } - MethodHandler mi = new OObjectProxyMethodHandler(doc); - try { - T newEntity; - if (iArgs != null && iArgs.length > 0) { - if (isInnerClass) { - if (iEnclosingInstance == null) { - iEnclosingInstance = iClass.getEnclosingClass().newInstance(); - } - Object[] newArgs = new Object[iArgs.length + 1]; - newArgs[0] = iEnclosingInstance; - for (int i = 0; i < iArgs.length; i++) { - newArgs[i + 1] = iArgs[i]; - } - iArgs = newArgs; - } - Constructor<T> constructor = null; - for (Constructor<?> constr : c.getConstructors()) { - boolean found = true; - if (constr.getParameterTypes().length == iArgs.length) { - for (int i = 0; i < constr.getParameterTypes().length; i++) { - Class<?> parameterType = constr.getParameterTypes()[i]; - if (parameterType.isPrimitive()) { - if (!isPrimitiveParameterCorrect(parameterType, iArgs[i])) { - found = false; - break; - } - } else if (iArgs[i] != null && !parameterType.isAssignableFrom(iArgs[i].getClass())) { - found = false; - break; - } - } - } else { - continue; - } - if (found) { - constructor = (Constructor<T>) constr; - break; - } - } - if (constructor != null) { - newEntity = (T) constructor.newInstance(iArgs); - initDocument(iClass, newEntity, doc, (ODatabaseObject) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner()); - } else { - if (iEnclosingInstance != null) - newEntity = createInstanceNoParameters(c, iEnclosingInstance); - else - newEntity = createInstanceNoParameters(c, iClass); - } - } else { - if (iEnclosingInstance != null) - newEntity = createInstanceNoParameters(c, iEnclosingInstance); - else - newEntity = createInstanceNoParameters(c, iClass); - } - ((Proxy) newEntity).setHandler(mi); - if (OObjectEntitySerializer.hasBoundedDocumentField(iClass)) - OObjectEntitySerializer.setFieldValue(OObjectEntitySerializer.getBoundedDocumentField(iClass), newEntity, doc); - return newEntity; - } catch (InstantiationException ie) { - OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), ie); - } catch (IllegalAccessException iae) { - OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), iae); - } catch (IllegalArgumentException iae) { - OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), iae); - } catch (SecurityException se) { - OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), se); - } catch (InvocationTargetException ite) { - OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), ite); - } catch (NoSuchMethodException nsme) { - OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), nsme); - } - return null; - } + @SuppressWarnings("unchecked") + public <T> T getProxiedInstance(final Class<T> iClass, Object iEnclosingInstance, final ODocument doc, Object... iArgs) { + if (iClass == null) { + throw new OSerializationException("Type " + doc.getClassName() + + " cannot be serialized because is not part of registered entities. To fix this error register this class"); + } + final Class<T> c; + boolean isInnerClass = iClass.getEnclosingClass() != null; + if (Proxy.class.isAssignableFrom(iClass)) { + c = iClass; + } else { + ProxyFactory f = new ProxyFactory(); + f.setSuperclass(iClass); + f.setFilter(new MethodFilter() { + public boolean isHandled(Method m) { + final String methodName = m.getName(); + try { + return (isSetterMethod(methodName, m) || isGetterMethod(methodName, m) || methodName.equals("equals") || methodName + .equals("hashCode")); + } catch (NoSuchFieldException nsfe) { + OLogManager.instance().warn(this, "Error handling the method %s in class %s", nsfe, m.getName(), iClass.getName()); + return false; + } catch (SecurityException se) { + OLogManager.instance().warn(this, "", se, m.getName(), iClass.getName()); + return false; + } + } + }); + c = f.createClass(); + } + MethodHandler mi = new OObjectProxyMethodHandler(doc); + try { + T newEntity; + if (iArgs != null && iArgs.length > 0) { + if (isInnerClass) { + if (iEnclosingInstance == null) { + iEnclosingInstance = iClass.getEnclosingClass().newInstance(); + } + Object[] newArgs = new Object[iArgs.length + 1]; + newArgs[0] = iEnclosingInstance; + for (int i = 0; i < iArgs.length; i++) { + newArgs[i + 1] = iArgs[i]; + } + iArgs = newArgs; + } + Constructor<T> constructor = null; + for (Constructor<?> constr : c.getConstructors()) { + boolean found = true; + if (constr.getParameterTypes().length == iArgs.length) { + for (int i = 0; i < constr.getParameterTypes().length; i++) { + Class<?> parameterType = constr.getParameterTypes()[i]; + if (parameterType.isPrimitive()) { + if (!isPrimitiveParameterCorrect(parameterType, iArgs[i])) { + found = false; + break; + } + } else if (iArgs[i] != null && !parameterType.isAssignableFrom(iArgs[i].getClass())) { + found = false; + break; + } + } + } else { + continue; + } + if (found) { + constructor = (Constructor<T>) constr; + break; + } + } + if (constructor != null) { + newEntity = (T) constructor.newInstance(iArgs); + initDocument(iClass, newEntity, doc, (ODatabaseObject) ODatabaseRecordThreadLocal.INSTANCE.get().getDatabaseOwner()); + } else { + if (iEnclosingInstance != null) + newEntity = createInstanceNoParameters(c, iEnclosingInstance); + else + newEntity = createInstanceNoParameters(c, iClass); + } + } else { + if (iEnclosingInstance != null) + newEntity = createInstanceNoParameters(c, iEnclosingInstance); + else + newEntity = createInstanceNoParameters(c, iClass); + } + ((Proxy) newEntity).setHandler(mi); + if (OObjectEntitySerializer.hasBoundedDocumentField(iClass)) + OObjectEntitySerializer.setFieldValue(OObjectEntitySerializer.getBoundedDocumentField(iClass), newEntity, doc); + return newEntity; + } catch (InstantiationException ie) { + OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), ie); + } catch (IllegalAccessException iae) { + OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), iae); + } catch (IllegalArgumentException iae) { + OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), iae); + } catch (SecurityException se) { + OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), se); + } catch (InvocationTargetException ite) { + OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), ite); + } catch (NoSuchMethodException nsme) { + OLogManager.instance().error(this, "Error creating proxied instance for class " + iClass.getName(), nsme); + } + return null; + } - public static synchronized OObjectEntityEnhancer getInstance() { - return instance; - } + public static synchronized OObjectEntityEnhancer getInstance() { + return instance; + } - private boolean isSetterMethod(String fieldName, Method m) throws SecurityException, NoSuchFieldException { - if (!fieldName.startsWith("set") || !checkIfFirstCharAfterPrefixIsUpperCase(fieldName, "set")) - return false; - if (m.getParameterTypes() != null && m.getParameterTypes().length != 1) - return false; - return !OObjectEntitySerializer.isTransientField(m.getDeclaringClass(), getFieldName(m)); - } + private boolean isSetterMethod(String fieldName, Method m) throws SecurityException, NoSuchFieldException { + if (!fieldName.startsWith("set") || !checkIfFirstCharAfterPrefixIsUpperCase(fieldName, "set")) + return false; + if (m.getParameterTypes() != null && m.getParameterTypes().length != 1) + return false; + return !OObjectEntitySerializer.isTransientField(m.getDeclaringClass(), getFieldName(m)); + } - private boolean isGetterMethod(String fieldName, Method m) throws SecurityException, NoSuchFieldException { - int prefixLength; - if (fieldName.startsWith("get") && checkIfFirstCharAfterPrefixIsUpperCase(fieldName, "get")) - prefixLength = "get".length(); - else if (fieldName.startsWith("is") && checkIfFirstCharAfterPrefixIsUpperCase(fieldName, "is")) - prefixLength = "is".length(); - else - return false; - if (m.getParameterTypes() != null && m.getParameterTypes().length > 0) - return false; - if (fieldName.length() <= prefixLength) - return false; - return !OObjectEntitySerializer.isTransientField(m.getDeclaringClass(), getFieldName(m)); - } + private boolean isGetterMethod(String fieldName, Method m) throws SecurityException, NoSuchFieldException { + int prefixLength; + if (fieldName.startsWith("get") && checkIfFirstCharAfterPrefixIsUpperCase(fieldName, "get")) + prefixLength = "get".length(); + else if (fieldName.startsWith("is") && checkIfFirstCharAfterPrefixIsUpperCase(fieldName, "is")) + prefixLength = "is".length(); + else + return false; + if (m.getParameterTypes() != null && m.getParameterTypes().length > 0) + return false; + if (fieldName.length() <= prefixLength) + return false; + return !OObjectEntitySerializer.isTransientField(m.getDeclaringClass(), getFieldName(m)); + } - protected String getFieldName(Method m) { - if (m.getName().startsWith("get")) - return getFieldName(m.getName(), "get"); - else if (m.getName().startsWith("set")) - return getFieldName(m.getName(), "set"); - else - return getFieldName(m.getName(), "is"); - } + protected String getFieldName(Method m) { + if (m.getName().startsWith("get")) + return getFieldName(m.getName(), "get"); + else if (m.getName().startsWith("set")) + return getFieldName(m.getName(), "set"); + else + return getFieldName(m.getName(), "is"); + } - protected String getFieldName(String methodName, String prefix) { - StringBuffer fieldName = new StringBuffer(); - fieldName.append(Character.toLowerCase(methodName.charAt(prefix.length()))); - for (int i = (prefix.length() + 1); i < methodName.length(); i++) { - fieldName.append(methodName.charAt(i)); - } - return fieldName.toString(); - } + protected String getFieldName(String methodName, String prefix) { + StringBuffer fieldName = new StringBuffer(); + fieldName.append(Character.toLowerCase(methodName.charAt(prefix.length()))); + for (int i = (prefix.length() + 1); i < methodName.length(); i++) { + fieldName.append(methodName.charAt(i)); + } + return fieldName.toString(); + } - private boolean checkIfFirstCharAfterPrefixIsUpperCase(String methodName, String prefix) { - return methodName.length() > prefix.length() ? Character.isUpperCase(methodName.charAt(prefix.length())) : false; - } + private boolean checkIfFirstCharAfterPrefixIsUpperCase(String methodName, String prefix) { + return methodName.length() > prefix.length() ? Character.isUpperCase(methodName.charAt(prefix.length())) : false; + } - private boolean isPrimitiveParameterCorrect(Class<?> primitiveClass, Object parameterValue) { - if (parameterValue == null) - return false; - final Class<?> parameterClass = parameterValue.getClass(); - if (Integer.TYPE.isAssignableFrom(primitiveClass)) - return Integer.class.isAssignableFrom(parameterClass); - else if (Double.TYPE.isAssignableFrom(primitiveClass)) - return Double.class.isAssignableFrom(parameterClass); - else if (Float.TYPE.isAssignableFrom(primitiveClass)) - return Float.class.isAssignableFrom(parameterClass); - else if (Long.TYPE.isAssignableFrom(primitiveClass)) - return Long.class.isAssignableFrom(parameterClass); - else if (Short.TYPE.isAssignableFrom(primitiveClass)) - return Short.class.isAssignableFrom(parameterClass); - else if (Byte.TYPE.isAssignableFrom(primitiveClass)) - return Byte.class.isAssignableFrom(parameterClass); - return false; - } + private boolean isPrimitiveParameterCorrect(Class<?> primitiveClass, Object parameterValue) { + if (parameterValue == null) + return false; + final Class<?> parameterClass = parameterValue.getClass(); + if (Integer.TYPE.isAssignableFrom(primitiveClass)) + return Integer.class.isAssignableFrom(parameterClass); + else if (Double.TYPE.isAssignableFrom(primitiveClass)) + return Double.class.isAssignableFrom(parameterClass); + else if (Float.TYPE.isAssignableFrom(primitiveClass)) + return Float.class.isAssignableFrom(parameterClass); + else if (Long.TYPE.isAssignableFrom(primitiveClass)) + return Long.class.isAssignableFrom(parameterClass); + else if (Short.TYPE.isAssignableFrom(primitiveClass)) + return Short.class.isAssignableFrom(parameterClass); + else if (Byte.TYPE.isAssignableFrom(primitiveClass)) + return Byte.class.isAssignableFrom(parameterClass); + return false; + } - @SuppressWarnings({ "rawtypes", "unchecked" }) - protected void initDocument(Class<?> iClass, Object iInstance, ODocument iDocument, ODatabaseObject db) - throws IllegalArgumentException, IllegalAccessException { - for (Class<?> currentClass = iClass; currentClass != Object.class;) { - for (Field f : currentClass.getDeclaredFields()) { - if (f.getName().equals("this$0")) - continue; - if (!f.isAccessible()) { - f.setAccessible(true); - } - Object o = f.get(iInstance); - if (o != null) { - if (OObjectEntitySerializer.isSerializedType(f)) { - if (o instanceof List<?>) { - List<?> list = new ArrayList(); - iDocument.field(f.getName(), list); - o = new OObjectCustomSerializerList(OObjectEntitySerializer.getSerializedType(f), iDocument, list, (List<?>) o); - f.set(iInstance, o); - } else if (o instanceof Set<?>) { - Set<?> set = new HashSet(); - iDocument.field(f.getName(), set); - o = new OObjectCustomSerializerSet(OObjectEntitySerializer.getSerializedType(f), iDocument, set, (Set<?>) o); - f.set(iInstance, o); - } else if (o instanceof Map<?, ?>) { - Map<?, ?> map = new HashMap(); - iDocument.field(f.getName(), map); - o = new OObjectCustomSerializerMap(OObjectEntitySerializer.getSerializedType(f), iDocument, map, (Map<?, ?>) o); - f.set(iInstance, o); - } else { - o = OObjectEntitySerializer.serializeFieldValue(o.getClass(), o); - iDocument.field(f.getName(), o); - } - } else { - iDocument.field(f.getName(), OObjectEntitySerializer.typeToStream(o, OType.getTypeByClass(f.getType()), db, iDocument)); - } - } - } - currentClass = currentClass.getSuperclass(); - } - } + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected void initDocument(Class<?> iClass, Object iInstance, ODocument iDocument, ODatabaseObject db) + throws IllegalArgumentException, IllegalAccessException { + for (Class<?> currentClass = iClass; currentClass != Object.class;) { + for (Field f : currentClass.getDeclaredFields()) { + if (f.getName().equals("this$0")) + continue; + if (!f.isAccessible()) { + f.setAccessible(true); + } + Object o = f.get(iInstance); + if (o != null) { + if (OObjectEntitySerializer.isSerializedType(f)) { + if (o instanceof List<?>) { + List<?> list = new ArrayList(); + iDocument.field(f.getName(), list); + o = new OObjectCustomSerializerList(OObjectEntitySerializer.getSerializedType(f), iDocument, list, (List<?>) o); + f.set(iInstance, o); + } else if (o instanceof Set<?>) { + Set<?> set = new HashSet(); + iDocument.field(f.getName(), set); + o = new OObjectCustomSerializerSet(OObjectEntitySerializer.getSerializedType(f), iDocument, set, (Set<?>) o); + f.set(iInstance, o); + } else if (o instanceof Map<?, ?>) { + Map<?, ?> map = new HashMap(); + iDocument.field(f.getName(), map); + o = new OObjectCustomSerializerMap(OObjectEntitySerializer.getSerializedType(f), iDocument, map, (Map<?, ?>) o); + f.set(iInstance, o); + } else { + o = OObjectEntitySerializer.serializeFieldValue(o.getClass(), o); + iDocument.field(f.getName(), o); + } + } else { + iDocument.field(f.getName(), OObjectEntitySerializer.typeToStream(o, OType.getTypeByClass(f.getType()), db, iDocument)); + } + } + } + currentClass = currentClass.getSuperclass(); + } + } - protected <T> T createInstanceNoParameters(Class<T> iProxiedClass, Class<?> iOriginalClass) throws SecurityException, - NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { - T instanceToReturn = null; - final Class<?> enclosingClass = iOriginalClass.getEnclosingClass(); + protected <T> T createInstanceNoParameters(Class<T> iProxiedClass, Class<?> iOriginalClass) throws SecurityException, + NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { + T instanceToReturn = null; + final Class<?> enclosingClass = iOriginalClass.getEnclosingClass(); - if (enclosingClass != null) { - Object instanceOfEnclosingClass = createInstanceNoParameters(enclosingClass, enclosingClass); + if (enclosingClass != null) { + Object instanceOfEnclosingClass = createInstanceNoParameters(enclosingClass, enclosingClass); - Constructor<T> ctor = iProxiedClass.getConstructor(enclosingClass); + Constructor<T> ctor = iProxiedClass.getConstructor(enclosingClass); - if (ctor != null) { - instanceToReturn = ctor.newInstance(instanceOfEnclosingClass); - } - } else { - instanceToReturn = iProxiedClass.newInstance(); - } + if (ctor != null) { + instanceToReturn = ctor.newInstance(instanceOfEnclosingClass); + } + } else { + try { + instanceToReturn = iProxiedClass.newInstance(); + } catch (InstantiationException e) { + OLogManager.instance().error(this, "Cannot create an instance of the enclosing class '%s'", iOriginalClass); + throw e; + } + } - return instanceToReturn; + return instanceToReturn; - } + } - protected <T> T createInstanceNoParameters(Class<T> iProxiedClass, Object iEnclosingInstance) throws SecurityException, - NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { - T instanceToReturn = null; - final Class<?> enclosingClass = iEnclosingInstance.getClass(); + protected <T> T createInstanceNoParameters(Class<T> iProxiedClass, Object iEnclosingInstance) throws SecurityException, + NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { + T instanceToReturn = null; + final Class<?> enclosingClass = iEnclosingInstance.getClass(); - if (enclosingClass != null) { + if (enclosingClass != null) { - Constructor<T> ctor = iProxiedClass.getConstructor(enclosingClass); + Constructor<T> ctor = iProxiedClass.getConstructor(enclosingClass); - if (ctor != null) { - instanceToReturn = ctor.newInstance(iEnclosingInstance); - } - } else { - instanceToReturn = iProxiedClass.newInstance(); - } + if (ctor != null) { + instanceToReturn = ctor.newInstance(iEnclosingInstance); + } + } else { + instanceToReturn = iProxiedClass.newInstance(); + } - return instanceToReturn; + return instanceToReturn; - } + } } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/DictionaryTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/DictionaryTest.java index 441c66d4c95..e99182ebd63 100644 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/DictionaryTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/DictionaryTest.java @@ -25,12 +25,14 @@ import com.orientechnologies.orient.core.record.ORecord; import com.orientechnologies.orient.core.record.impl.ORecordFlat; import com.orientechnologies.orient.object.db.OObjectDatabaseTx; -import com.orientechnologies.orient.object.enhancement.ExactEntity; @Test(groups = "dictionary") public class DictionaryTest { private String url; + public DictionaryTest() { + } + @Parameters(value = "url") public DictionaryTest(String iURL) { url = iURL; @@ -129,14 +131,29 @@ public void testDictionaryInTx() throws IOException { database.close(); } + public class ObjectDictionaryTest { + private String name; + + public ObjectDictionaryTest() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + @Test(dependsOnMethods = "testDictionaryMassiveCreate") public void testDictionaryWithPOJOs() throws IOException { OObjectDatabaseTx database = new OObjectDatabaseTx(url); database.open("admin", "admin"); - database.getEntityManager().registerEntityClass(ExactEntity.class); + database.getEntityManager().registerEntityClass(ObjectDictionaryTest.class); Assert.assertNull(database.getDictionary().get("testKey")); - database.getDictionary().put("testKey", new ExactEntity()); + database.getDictionary().put("testKey", new ObjectDictionaryTest()); Assert.assertNotNull(database.getDictionary().get("testKey")); database.close();
5a00916143eb6531f8fd848727d70b87edb21f60
Valadoc
libvaladoc: Avoid multiple imports
a
https://github.com/GNOME/vala/
diff --git a/src/libvaladoc/api/tree.vala b/src/libvaladoc/api/tree.vala index 55cfe6ec3e..cc662d13e8 100644 --- a/src/libvaladoc/api/tree.vala +++ b/src/libvaladoc/api/tree.vala @@ -274,14 +274,21 @@ public class Valadoc.Api.Tree { * @param import_directories List of directories where to find the files */ public void import_documentation (DocumentationImporter[] importers, string[] packages, string[] import_directories) { + HashSet<string> processed = new HashSet<string> (); foreach (string pkg_name in packages) { bool imported = false; foreach (DocumentationImporter importer in importers) { string? path = get_file_path ("%s.%s".printf (pkg_name, importer.file_extension), import_directories); + if (path == null) { + continue; + } + + path = realpath (path); + imported = true; - if (path != null) { + if (!processed.contains (path)) { importer.process (path); - imported = true; + processed.add (path); } }
29735e041d02b03084c22e02f8d74e90b3902bf9
Vala
gstreamer-0.10: make GstIterator a generic
c
https://github.com/GNOME/vala/
diff --git a/vapi/gstreamer-0.10.vapi b/vapi/gstreamer-0.10.vapi index 1d79120559..94316d6e51 100644 --- a/vapi/gstreamer-0.10.vapi +++ b/vapi/gstreamer-0.10.vapi @@ -390,7 +390,7 @@ namespace Gst { public class void install_std_props (...); public bool is_indexable (); public bool is_locked_state (); - public Gst.Iterator iterate_pads (); + public Gst.Iterator<Gst.Pad> iterate_pads (); public Gst.Iterator iterate_sink_pads (); public Gst.Iterator iterate_src_pads (); public bool link (Gst.Element dest); @@ -604,7 +604,7 @@ namespace Gst { } [Compact] [CCode (cheader_filename = "gst/gst.h")] - public class Iterator { + public class Iterator<T> { public uint32 cookie; public weak GLib.Mutex @lock; public void* master_cookie; @@ -612,16 +612,16 @@ namespace Gst { public GLib.Type type; [CCode (has_construct_function = false)] public Iterator (uint size, GLib.Type type, GLib.Mutex @lock, ref uint32 master_cookie, Gst.IteratorNextFunction next, Gst.IteratorItemFunction item, Gst.IteratorResyncFunction resync, Gst.IteratorFreeFunction free); - public void* find_custom (GLib.CompareFunc func); + public T find_custom (GLib.CompareFunc func, T user_data); public Gst.IteratorResult fold ([CCode (delegate_target_pos = 2.1)] Gst.IteratorFoldFunction func, Gst.Value? ret); public Gst.IteratorResult @foreach (GLib.Func func); [CCode (has_construct_function = false)] - public Iterator.list (GLib.Type type, GLib.Mutex @lock, ref uint32 master_cookie, GLib.List list, void* owner, Gst.IteratorItemFunction item, Gst.IteratorDisposeFunction free); - public Gst.IteratorResult next (out void* elem); + public Iterator.list (GLib.Type type, GLib.Mutex @lock, ref uint32 master_cookie, GLib.List<T> list, void* owner, Gst.IteratorItemFunction item, Gst.IteratorDisposeFunction free); + public Gst.IteratorResult next (out T elem); public void push (Gst.Iterator other); public void resync (); [CCode (has_construct_function = false)] - public Iterator.single (GLib.Type type, void* object, Gst.CopyFunction copy, GLib.FreeFunc free); + public Iterator.single (GLib.Type type, T object, Gst.CopyFunction copy, GLib.FreeFunc free); } [CCode (ref_function = "gst_message_ref", unref_function = "gst_message_unref", cheader_filename = "gst/gst.h")] public class Message : Gst.MiniObject { diff --git a/vapi/packages/gstreamer-0.10/gstreamer-0.10.metadata b/vapi/packages/gstreamer-0.10/gstreamer-0.10.metadata index f516fe9140..0ce94ab32b 100644 --- a/vapi/packages/gstreamer-0.10/gstreamer-0.10.metadata +++ b/vapi/packages/gstreamer-0.10/gstreamer-0.10.metadata @@ -171,6 +171,7 @@ gst_element_factory_create.name nullable="1" gst_element_factory_get_static_pad_templates type_arguments="StaticPadTemplate" gst_element_factory_find transfer_ownership="1" nullable="1" gst_element_factory_get_uri_protocols is_array="1" array_null_terminated="1" transfer_ownership="1" nullable="1" +gst_element_iterate_pads transfer_ownership="1" type_arguments="Pad" gst_error_get_message transfer_ownership="1" GstEvent base_class="GstMiniObject" GstEvent.mini_object hidden="1" @@ -225,19 +226,22 @@ gst_init_get_option_group transfer_ownership="1" gst_index_factory_make transfer_ownership="1" nullable="1" gst_index_factory_create transfer_ownership="1" gst_index_factory_find transfer_ownership="1" nullable="1" +GstIterator type_parameters="T" GstIterator.free hidden="1" GstIterator.next hidden="1" GstIterator.resync hidden="1" GstIterator.item hidden="1" GstIterator.pushed nullable="1" GstIterator.master_cookie type_name="pointer" -gst_iterator_next.elem is_out="1" +gst_iterator_next.elem type_name="T" is_out="1" transfer_ownership="1" gst_iterator_fold.func delegate_target_pos="2.1" gst_iterator_fold.ret nullable="1" -gst_iterator_find_custom.user_data hidden="0" +gst_iterator_new_list.list type_arguments="T" gst_iterator_new.master_cookie is_ref="1" gst_iterator_new_list.master_cookie is_ref="1" -gst_iterator_find_custom.user_data hidden="1" +gst_iterator_find_custom type_name="T" transfer_ownership="1" +gst_iterator_find_custom.user_data type_name="T" hidden="0" +gst_iterator_new_single.object type_name="T" gst_iterator_filter hidden="1" GstIteratorNextFunction.result is_out="1" GstIteratorFoldFunction.ret is_ref="1"
300e643ce781132b7276962b1a8223b3ebde5fde
Valadoc
ctypresolver: signals: register default implementations
a
https://github.com/GNOME/vala/
diff --git a/src/libvaladoc/ctyperesolver.vala b/src/libvaladoc/ctyperesolver.vala index 3c30dfdf54..6901d960e7 100644 --- a/src/libvaladoc/ctyperesolver.vala +++ b/src/libvaladoc/ctyperesolver.vala @@ -315,6 +315,7 @@ public class Valadoc.CTypeResolver : Visitor { string parent_cname = get_parent_type_cname (item); assert (parent_cname != null); + string? default_impl_cname = item.get_default_impl_cname (); string cname = item.get_cname (); register_symbol (parent_cname+"::"+cname, item); @@ -341,6 +342,10 @@ public class Valadoc.CTypeResolver : Visitor { foreach (Class cl in classes) { register_symbol (cl.get_cname () + "::" + cname, item); } + + if (default_impl_cname != null) { + register_symbol (default_impl_cname, item); + } } /**
9304ec103d2d104e11c9f96c87864d6f7a026b64
kotlin
wrongly added test removed (correct one was added- before by Zhenja)--
p
https://github.com/JetBrains/kotlin
diff --git a/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java b/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java index 97335a21b9bba..9b160e88e0373 100644 --- a/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java +++ b/compiler/android-tests/tests/org/jetbrains/jet/compiler/android/SpecialFiles.java @@ -122,8 +122,6 @@ private static void fillExcludedFiles() { excludedFiles.add("kt1779.kt"); // Bug KT-2202 - private fun tryToComputeNext() in AbstractIterator.kt excludedFiles.add("kt344.jet"); // Bug KT-2251 excludedFiles.add("kt529.kt"); // Bug - - excludedFiles.add("kt2981.kt"); // with java } private SpecialFiles() {
3fbdf05921125b2bff7e4b914e9e060814010a6f
kotlin
Added some new test for java8--
p
https://github.com/JetBrains/kotlin
diff --git a/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJava8CodegenTestGenerated.java b/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJava8CodegenTestGenerated.java index 6bae70acab423..4e17e4b4d7a76 100644 --- a/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJava8CodegenTestGenerated.java +++ b/compiler/java8-tests/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJava8CodegenTestGenerated.java @@ -35,9 +35,15 @@ public void testAllFilesPresentInBoxWithJava() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/boxWithJava"), Pattern.compile("^([^\\.]+)$"), true); } - @TestMetadata("defaultMethodCall") - public void testDefaultMethodCall() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/"); + @TestMetadata("defaultMethodCallFromTrait") + public void testDefaultMethodCallFromTrait() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/java8/boxWithJava/defaultMethodCallFromTrait/"); + doTestWithJava(fileName); + } + + @TestMetadata("defaultMethodCallViaClass") + public void testDefaultMethodCallViaClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaClass/"); doTestWithJava(fileName); } @@ -47,12 +53,24 @@ public void testDefaultMethodCallViaTrait() throws Exception { doTestWithJava(fileName); } + @TestMetadata("defaultMethodOverride") + public void testDefaultMethodOverride() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/java8/boxWithJava/defaultMethodOverride/"); + doTestWithJava(fileName); + } + @TestMetadata("dontDelegateToDefaultMethods") public void testDontDelegateToDefaultMethods() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/java8/boxWithJava/dontDelegateToDefaultMethods/"); doTestWithJava(fileName); } + @TestMetadata("inheritKotlin") + public void testInheritKotlin() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/java8/boxWithJava/inheritKotlin/"); + doTestWithJava(fileName); + } + @TestMetadata("samOnInterfaceWithDefaultMethod") public void testSamOnInterfaceWithDefaultMethod() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/java8/boxWithJava/samOnInterfaceWithDefaultMethod/"); diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.java b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallFromTrait/Simple.java similarity index 100% rename from compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.java rename to compiler/testData/codegen/java8/boxWithJava/defaultMethodCallFromTrait/Simple.java diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallFromTrait/defaultCall.kt b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallFromTrait/defaultCall.kt new file mode 100644 index 0000000000000..55133e938783c --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallFromTrait/defaultCall.kt @@ -0,0 +1,14 @@ +trait KTrait : Simple { + fun bar(): String { + return test("O") + Simple.testStatic("O") + } +} + +class Test : KTrait {} + +fun box(): String { + val test = Test().bar() + if (test != "OKOK") return "fail $test" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaClass/Simple.java b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaClass/Simple.java new file mode 100644 index 0000000000000..9e37ab676594c --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaClass/Simple.java @@ -0,0 +1,9 @@ +interface Simple { + default String test(String s) { + return s + "K"; + } + + static String testStatic(String s) { + return s + "K"; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.kt b/compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaClass/defaultCall.kt similarity index 100% rename from compiler/testData/codegen/java8/boxWithJava/defaultMethodCall/Simple.kt rename to compiler/testData/codegen/java8/boxWithJava/defaultMethodCallViaClass/defaultCall.kt diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodOverride/Simple.java b/compiler/testData/codegen/java8/boxWithJava/defaultMethodOverride/Simple.java new file mode 100644 index 0000000000000..552a157fcb70b --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/defaultMethodOverride/Simple.java @@ -0,0 +1,5 @@ +interface Simple { + default String test(String s) { + return s + "Fail"; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/boxWithJava/defaultMethodOverride/override.kt b/compiler/testData/codegen/java8/boxWithJava/defaultMethodOverride/override.kt new file mode 100644 index 0000000000000..d834a1f60cb93 --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/defaultMethodOverride/override.kt @@ -0,0 +1,13 @@ +trait KTrait: Simple { + override fun test(s: String): String { + return s + "K" + } +} + +class Test : KTrait { + +} + +fun box(): String { + return Test().test("O") +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/boxWithJava/dontDelegateToDefaultMethods/delegation.kt b/compiler/testData/codegen/java8/boxWithJava/dontDelegateToDefaultMethods/dontDelegate.kt similarity index 100% rename from compiler/testData/codegen/java8/boxWithJava/dontDelegateToDefaultMethods/delegation.kt rename to compiler/testData/codegen/java8/boxWithJava/dontDelegateToDefaultMethods/dontDelegate.kt diff --git a/compiler/testData/codegen/java8/boxWithJava/inheritKotlin/Simple.java b/compiler/testData/codegen/java8/boxWithJava/inheritKotlin/Simple.java new file mode 100644 index 0000000000000..02c979c1af19a --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/inheritKotlin/Simple.java @@ -0,0 +1,5 @@ +interface Simple extends KTrait { + default String test() { + return "simple"; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/java8/boxWithJava/inheritKotlin/defaultCall.kt b/compiler/testData/codegen/java8/boxWithJava/inheritKotlin/defaultCall.kt new file mode 100644 index 0000000000000..c9572f45f3731 --- /dev/null +++ b/compiler/testData/codegen/java8/boxWithJava/inheritKotlin/defaultCall.kt @@ -0,0 +1,23 @@ +trait KTrait { + fun test(): String { + return "base"; + } +} + +class Test : Simple { + + fun bar(): String { + return super.test() + } + +} + +fun box(): String { + val test = Test().test() + if (test != "simple") return "fail $test" + + val bar = Test().bar() + if (bar != "simple") return "fail 2 $bar" + + return "OK" +} \ No newline at end of file
615fc435cc88c2c4fe66e9359f1d69e5eb134d18
elasticsearch
Http Transport: Allow to configure- `max_header_size`
a
https://github.com/elastic/elasticsearch
diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java b/modules/elasticsearch/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java index 180d513c5a1c1..45f05e7be1ad9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/http/netty/NettyHttpServerTransport.java @@ -82,13 +82,16 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent<HttpSer private final NetworkService networkService; - private final ByteSizeValue maxContentLength; + final ByteSizeValue maxContentLength; + final ByteSizeValue maxInitialLineLength; + final ByteSizeValue maxHeaderSize; + final ByteSizeValue maxChunkSize; private final int workerCount; private final boolean blockingServer; - private final boolean compression; + final boolean compression; private final int compressionLevel; @@ -114,7 +117,7 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent<HttpSer private volatile Channel serverChannel; - private volatile OpenChannelsHandler serverOpenChannels; + OpenChannelsHandler serverOpenChannels; private volatile HttpServerAdapter httpServerAdapter; @@ -122,6 +125,9 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent<HttpSer super(settings); this.networkService = networkService; ByteSizeValue maxContentLength = componentSettings.getAsBytesSize("max_content_length", settings.getAsBytesSize("http.max_content_length", new ByteSizeValue(100, ByteSizeUnit.MB))); + this.maxChunkSize = componentSettings.getAsBytesSize("max_chunk_size", settings.getAsBytesSize("http.max_chunk_size", new ByteSizeValue(8, ByteSizeUnit.KB))); + this.maxHeaderSize = componentSettings.getAsBytesSize("max_header_size", settings.getAsBytesSize("http.max_header_size", new ByteSizeValue(8, ByteSizeUnit.KB))); + this.maxInitialLineLength = componentSettings.getAsBytesSize("max_initial_line_length", settings.getAsBytesSize("http.max_initial_line_length", new ByteSizeValue(4, ByteSizeUnit.KB))); this.workerCount = componentSettings.getAsInt("worker_count", Runtime.getRuntime().availableProcessors() * 2); this.blockingServer = settings.getAsBoolean("http.blocking_server", settings.getAsBoolean(TCP_BLOCKING_SERVER, settings.getAsBoolean(TCP_BLOCKING, false))); this.port = componentSettings.get("port", settings.get("http.port", "9200-9300")); @@ -142,6 +148,9 @@ public class NettyHttpServerTransport extends AbstractLifecycleComponent<HttpSer maxContentLength = new ByteSizeValue(100, ByteSizeUnit.MB); } this.maxContentLength = maxContentLength; + + logger.debug("using max_chunk_size[{}], max_header_size[{}], max_initial_line_length[{}], max_content_length[{}]", + maxChunkSize, maxHeaderSize, maxInitialLineLength, this.maxContentLength); } public void httpServerAdapter(HttpServerAdapter httpServerAdapter) { @@ -163,27 +172,7 @@ public void httpServerAdapter(HttpServerAdapter httpServerAdapter) { workerCount)); } - final HttpRequestHandler requestHandler = new HttpRequestHandler(this); - - ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() { - @Override public ChannelPipeline getPipeline() throws Exception { - ChannelPipeline pipeline = Channels.pipeline(); - pipeline.addLast("openChannels", serverOpenChannels); - pipeline.addLast("decoder", new HttpRequestDecoder()); - if (compression) { - pipeline.addLast("decoder_compress", new HttpContentDecompressor()); - } - pipeline.addLast("aggregator", new HttpChunkAggregator((int) maxContentLength.bytes())); - pipeline.addLast("encoder", new HttpResponseEncoder()); - if (compression) { - pipeline.addLast("encoder_compress", new HttpContentCompressor(compressionLevel)); - } - pipeline.addLast("handler", requestHandler); - return pipeline; - } - }; - - serverBootstrap.setPipelineFactory(pipelineFactory); + serverBootstrap.setPipelineFactory(new MyChannelPipelineFactory(this)); if (tcpNoDelay != null) { serverBootstrap.setOption("child.tcpNoDelay", tcpNoDelay); @@ -287,4 +276,36 @@ void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Excepti } } } + + static class MyChannelPipelineFactory implements ChannelPipelineFactory { + + private final NettyHttpServerTransport transport; + + private final HttpRequestHandler requestHandler; + + MyChannelPipelineFactory(NettyHttpServerTransport transport) { + this.transport = transport; + this.requestHandler = new HttpRequestHandler(transport); + } + + @Override public ChannelPipeline getPipeline() throws Exception { + ChannelPipeline pipeline = Channels.pipeline(); + pipeline.addLast("openChannels", transport.serverOpenChannels); + pipeline.addLast("decoder", new HttpRequestDecoder( + (int) transport.maxInitialLineLength.bytes(), + (int) transport.maxHeaderSize.bytes(), + (int) transport.maxChunkSize.bytes() + )); + if (transport.compression) { + pipeline.addLast("decoder_compress", new HttpContentDecompressor()); + } + pipeline.addLast("aggregator", new HttpChunkAggregator((int) transport.maxContentLength.bytes())); + pipeline.addLast("encoder", new HttpResponseEncoder()); + if (transport.compression) { + pipeline.addLast("encoder_compress", new HttpContentCompressor(transport.compressionLevel)); + } + pipeline.addLast("handler", requestHandler); + return pipeline; + } + } }
87fac898aa1b973c701daaa8c96a13442cbf72fe
tapiji
Defines the babel editor dependency to the PDE as optional. Fixes Issue 45. Fixes Issue 51. Uses Java reflection for accessing PDE related classes. If the PDE plug-in isn't loaded within the currently executed Eclipse instance, the Babel editor skips checks for Fragment projects. Also fixes a minor typo within the babel editor UI.
a
https://github.com/tapiji/tapiji
diff --git a/org.eclipse.babel.core/META-INF/MANIFEST.MF b/org.eclipse.babel.core/META-INF/MANIFEST.MF index ddee7a2a..9cd02dbd 100644 --- a/org.eclipse.babel.core/META-INF/MANIFEST.MF +++ b/org.eclipse.babel.core/META-INF/MANIFEST.MF @@ -23,4 +23,4 @@ Require-Bundle: org.eclipse.core.databinding, org.eclipse.core.runtime, org.eclipselabs.tapiji.translator.rbe;bundle-version="0.0.2";visibility:=reexport, org.eclipse.jdt.core;bundle-version="3.6.2" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/org.eclipse.babel.editor/META-INF/MANIFEST.MF b/org.eclipse.babel.editor/META-INF/MANIFEST.MF index e4e2225f..47e1973b 100644 --- a/org.eclipse.babel.editor/META-INF/MANIFEST.MF +++ b/org.eclipse.babel.editor/META-INF/MANIFEST.MF @@ -16,11 +16,11 @@ Require-Bundle: org.eclipse.ui, org.eclipse.jdt.core;bundle-version="3.2.0", org.eclipse.ltk.core.refactoring, org.eclipse.ltk.ui.refactoring, - org.eclipse.pde.core;bundle-version="3.2.0", org.junit;resolution:=optional, - org.eclipse.babel.core;visibility:=reexport + org.eclipse.babel.core;visibility:=reexport, + org.eclipse.pde.core;resolution:=optional Bundle-ActivationPolicy: lazy Bundle-Vendor: %plugin.provider -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-Localization: plugin Export-Package: org.eclipse.babel.editor.api diff --git a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/actions/AddKeyAction.java b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/actions/AddKeyAction.java index 3167aa30..7444a09f 100644 --- a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/actions/AddKeyAction.java +++ b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/actions/AddKeyAction.java @@ -22,7 +22,7 @@ /** * @author Pascal Essiembre - * + * */ public class AddKeyAction extends AbstractTreeAction { @@ -30,38 +30,37 @@ public class AddKeyAction extends AbstractTreeAction { * */ public AddKeyAction(MessagesEditor editor, TreeViewer treeViewer) { - super(editor, treeViewer); - setText(MessagesEditorPlugin.getString("key.add")); //$NON-NLS-1$ - setImageDescriptor(UIUtils.getImageDescriptor(UIUtils.IMAGE_ADD)); - setToolTipText("TODO put something here"); //TODO put tooltip + super(editor, treeViewer); + setText(MessagesEditorPlugin.getString("key.add") + " ..."); //$NON-NLS-1$ + setImageDescriptor(UIUtils.getImageDescriptor(UIUtils.IMAGE_ADD)); + setToolTipText("TODO put something here"); // TODO put tooltip } - /** * @see org.eclipse.jface.action.Action#run() */ + @Override public void run() { - KeyTreeNode node = getNodeSelection(); - String key = node.getMessageKey(); - String msgHead = MessagesEditorPlugin.getString("dialog.add.head"); - String msgBody = MessagesEditorPlugin.getString("dialog.add.body"); - InputDialog dialog = new InputDialog( - getShell(), msgHead, msgBody, key, new IInputValidator() { - public String isValid(String newText) { - if (getBundleGroup().isMessageKey(newText)) { - return MessagesEditorPlugin.getString( - "dialog.error.exists"); - } - return null; - } - }); - dialog.open(); - if (dialog.getReturnCode() == Window.OK ) { - String inputKey = dialog.getValue(); - MessagesBundleGroup messagesBundleGroup = getBundleGroup(); - messagesBundleGroup.addMessages(inputKey); - } + KeyTreeNode node = getNodeSelection(); + String key = node.getMessageKey(); + String msgHead = MessagesEditorPlugin.getString("dialog.add.head"); + String msgBody = MessagesEditorPlugin.getString("dialog.add.body"); + InputDialog dialog = new InputDialog(getShell(), msgHead, msgBody, key, + new IInputValidator() { + public String isValid(String newText) { + if (getBundleGroup().isMessageKey(newText)) { + return MessagesEditorPlugin + .getString("dialog.error.exists"); + } + return null; + } + }); + dialog.open(); + if (dialog.getReturnCode() == Window.OK) { + String inputKey = dialog.getValue(); + MessagesBundleGroup messagesBundleGroup = getBundleGroup(); + messagesBundleGroup.addMessages(inputKey); + } } - - + } diff --git a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/actions/RenameKeyAction.java b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/actions/RenameKeyAction.java index e77d9883..a746bbe4 100644 --- a/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/actions/RenameKeyAction.java +++ b/org.eclipse.babel.editor/src/org/eclipse/babel/editor/tree/actions/RenameKeyAction.java @@ -22,7 +22,7 @@ /** * @author Pascal Essiembre - * + * */ public class RenameKeyAction extends AbstractTreeAction { @@ -30,28 +30,30 @@ public class RenameKeyAction extends AbstractTreeAction { * */ public RenameKeyAction(MessagesEditor editor, TreeViewer treeViewer) { - super(editor, treeViewer); - setText(MessagesEditorPlugin.getString("key.rename")); //$NON-NLS-1$ - setImageDescriptor(UIUtils.getImageDescriptor(UIUtils.IMAGE_RENAME)); - setToolTipText("TODO put something here"); //TODO put tooltip + super(editor, treeViewer); + setText(MessagesEditorPlugin.getString("key.rename") + " ..."); //$NON-NLS-1$ + setImageDescriptor(UIUtils.getImageDescriptor(UIUtils.IMAGE_RENAME)); + setToolTipText("TODO put something here"); // TODO put tooltip } - /** * @see org.eclipse.jface.action.Action#run() */ + @Override public void run() { - KeyTreeNode node = getNodeSelection(); + KeyTreeNode node = getNodeSelection(); + + // Rename single item + RenameKeyProcessor refactoring = new RenameKeyProcessor(node, + getBundleGroup()); - // Rename single item - RenameKeyProcessor refactoring = new RenameKeyProcessor(node, getBundleGroup()); - - RefactoringWizard wizard = new RenameKeyWizard(node, refactoring); - try { - RefactoringWizardOpenOperation operation= new RefactoringWizardOpenOperation(wizard); - operation.run(getShell(), "Introduce Indirection"); - } catch (InterruptedException exception) { - // Do nothing - } + RefactoringWizard wizard = new RenameKeyWizard(node, refactoring); + try { + RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation( + wizard); + operation.run(getShell(), "Introduce Indirection"); + } catch (InterruptedException exception) { + // Do nothing + } } } diff --git a/org.eclipse.babel.editor/src/org/eclipse/pde/nls/internal/ui/model/ResourceBundleModel.java b/org.eclipse.babel.editor/src/org/eclipse/pde/nls/internal/ui/model/ResourceBundleModel.java index 0123378e..e6addce3 100644 --- a/org.eclipse.babel.editor/src/org/eclipse/pde/nls/internal/ui/model/ResourceBundleModel.java +++ b/org.eclipse.babel.editor/src/org/eclipse/pde/nls/internal/ui/model/ResourceBundleModel.java @@ -32,9 +32,7 @@ import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.pde.core.plugin.IFragmentModel; -import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.core.plugin.PluginRegistry; +import org.eclipse.osgi.service.resolver.BundleDescription; /** * A <code>ResourceBundleModel</code> is the host for all @@ -185,112 +183,141 @@ private void populateFromWorkspace(IProgressMonitor monitor) IJavaProject javaProject = (IJavaProject) project .getNature(JAVA_NATURE); - - // Plugin and fragment projects - IPluginModelBase pluginModel = PluginRegistry - .findModel(project); String pluginId = null; - if (pluginModel != null) { - // Get plugin id - pluginId = pluginModel.getBundleDescription().getName(); // - // OSGi bundle name - if (pluginId == null) { - pluginId = pluginModel.getPluginBase().getId(); // non-OSGi - // plug-in id - } - boolean isFragment = pluginModel instanceof IFragmentModel; - if (isFragment) { - IFragmentModel fragmentModel = (IFragmentModel) pluginModel; - pluginId = fragmentModel.getFragment().getPluginId(); - } - // Look for additional 'nl' resources - IFolder nl = project.getFolder("nl"); //$NON-NLS-1$ - if (isFragment && nl.exists()) { - IResource[] members = nl.members(); - for (IResource member : members) { - if (member instanceof IFolder) { - IFolder langFolder = (IFolder) member; - String language = langFolder.getName(); - - // Collect property files - IFile[] propertyFiles = collectPropertyFiles(langFolder); - for (IFile file : propertyFiles) { - // Compute path name - IPath path = file.getProjectRelativePath(); - String country = ""; //$NON-NLS-1$ - String packageName = null; - int segmentCount = path.segmentCount(); - if (segmentCount > 1) { - StringBuilder builder = new StringBuilder(); - - // Segment 0: 'nl' - // Segment 1: language code - // Segment 2: (country code) - int begin = 2; - if (segmentCount > 2 - && isCountry(path.segment(2))) { - begin = 3; - country = path.segment(2); - } + try { + Class IFragmentModel = Class + .forName("org.eclipse.pde.core.plugin.IFragmentModel"); + Class IPluginModelBase = Class + .forName("org.eclipse.pde.core.plugin.IPluginModelBase"); + Class PluginRegistry = Class + .forName("org.eclipse.pde.core.plugin.PluginRegistry"); + Class IPluginBase = Class + .forName("org.eclipse.pde.core.plugin.IPluginBase"); + Class PluginFragmentModel = Class + .forName("org.eclipse.core.runtime.model.PluginFragmentModel"); + + // Plugin and fragment projects + Class pluginModel = (Class) PluginRegistry.getMethod( + "findModel", IProject.class).invoke(null, project); + if (pluginModel != null) { + // Get plugin id + BundleDescription bd = (BundleDescription) IPluginModelBase + .getMethod("getBundleDescription").invoke( + pluginModel); + pluginId = bd.getName(); + // OSGi bundle name + if (pluginId == null) { + Object pluginBase = IPluginModelBase.getMethod( + "getPluginBase").invoke(pluginModel); + pluginId = (String) IPluginBase.getMethod("getId") + .invoke(pluginBase); // non-OSGi + // plug-in id + } + + boolean isFragment = IFragmentModel + .isInstance(pluginModel); + if (isFragment) { + Object pfm = IFragmentModel + .getMethod("getFragment"); + pluginId = (String) PluginFragmentModel.getMethod( + "getPluginId").invoke(pfm); + } + + // Look for additional 'nl' resources + IFolder nl = project.getFolder("nl"); //$NON-NLS-1$ + if (isFragment && nl.exists()) { + IResource[] members = nl.members(); + for (IResource member : members) { + if (member instanceof IFolder) { + IFolder langFolder = (IFolder) member; + String language = langFolder.getName(); + + // Collect property files + IFile[] propertyFiles = collectPropertyFiles(langFolder); + for (IFile file : propertyFiles) { + // Compute path name + IPath path = file + .getProjectRelativePath(); + String country = ""; //$NON-NLS-1$ + String packageName = null; + int segmentCount = path.segmentCount(); + if (segmentCount > 1) { + StringBuilder builder = new StringBuilder(); + + // Segment 0: 'nl' + // Segment 1: language code + // Segment 2: (country code) + int begin = 2; + if (segmentCount > 2 + && isCountry(path + .segment(2))) { + begin = 3; + country = path.segment(2); + } - for (int i = begin; i < segmentCount - 1; i++) { - if (i > begin) - builder.append('.'); - builder.append(path.segment(i)); + for (int i = begin; i < segmentCount - 1; i++) { + if (i > begin) + builder.append('.'); + builder.append(path.segment(i)); + } + packageName = builder.toString(); } - packageName = builder.toString(); - } - String baseName = getBaseName(file - .getName()); + String baseName = getBaseName(file + .getName()); - ResourceBundleFamily family = getOrCreateFamily( - project.getName(), pluginId, - packageName, baseName); - addBundle(family, - getLocale(language, country), file); + ResourceBundleFamily family = getOrCreateFamily( + project.getName(), pluginId, + packageName, baseName); + addBundle(family, + getLocale(language, country), + file); + } } } } - } - // Collect property files - if (isFragment || javaProject == null) { - IFile[] propertyFiles = collectPropertyFiles(project); - for (IFile file : propertyFiles) { - IPath path = file.getProjectRelativePath(); - int segmentCount = path.segmentCount(); - - if (segmentCount > 0 - && path.segment(0).equals("nl")) //$NON-NLS-1$ - continue; // 'nl' resource have been processed - // above - - // Guess package name - String packageName = null; - if (segmentCount > 1) { - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < segmentCount - 1; i++) { - if (i > 0) - builder.append('.'); - builder.append(path.segment(i)); + // Collect property files + if (isFragment || javaProject == null) { + IFile[] propertyFiles = collectPropertyFiles(project); + for (IFile file : propertyFiles) { + IPath path = file.getProjectRelativePath(); + int segmentCount = path.segmentCount(); + + if (segmentCount > 0 + && path.segment(0).equals("nl")) //$NON-NLS-1$ + continue; // 'nl' resource have been + // processed + // above + + // Guess package name + String packageName = null; + if (segmentCount > 1) { + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < segmentCount - 1; i++) { + if (i > 0) + builder.append('.'); + builder.append(path.segment(i)); + } + packageName = builder.toString(); } - packageName = builder.toString(); - } - String baseName = getBaseName(file.getName()); - String language = getLanguage(file.getName()); - String country = getCountry(file.getName()); + String baseName = getBaseName(file.getName()); + String language = getLanguage(file.getName()); + String country = getCountry(file.getName()); - ResourceBundleFamily family = getOrCreateFamily( - project.getName(), pluginId, packageName, - baseName); - addBundle(family, getLocale(language, country), - file); + ResourceBundleFamily family = getOrCreateFamily( + project.getName(), pluginId, + packageName, baseName); + addBundle(family, getLocale(language, country), + file); + } } - } + } + } catch (Throwable e) { + // MessagesEditorPlugin.log(e); } // Look for resource bundles in Java packages (output folders,
b5ba6979b7bfd216166f040ec1d66c425307516c
hadoop
YARN-3583. Support of NodeLabel object instead of- plain String in YarnClient side. (Sunil G via wangda)--(cherry picked from commit 563eb1ad2ae848a23bbbf32ebfaf107e8fa14e87)-(cherry picked from commit b0d22b0c606fad6b4ab5443c0aed07c829b46726)-
p
https://github.com/apache/hadoop
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ResourceMgrDelegate.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ResourceMgrDelegate.java index 2b7cd5fd6f2d1..90f6876c17a46 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ResourceMgrDelegate.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ResourceMgrDelegate.java @@ -444,19 +444,19 @@ public ReservationDeleteResponse deleteReservation( } @Override - public Map<NodeId, Set<String>> getNodeToLabels() throws YarnException, + public Map<NodeId, Set<NodeLabel>> getNodeToLabels() throws YarnException, IOException { return client.getNodeToLabels(); } @Override - public Map<String, Set<NodeId>> getLabelsToNodes() throws YarnException, + public Map<NodeLabel, Set<NodeId>> getLabelsToNodes() throws YarnException, IOException { return client.getLabelsToNodes(); } @Override - public Map<String, Set<NodeId>> getLabelsToNodes(Set<String> labels) + public Map<NodeLabel, Set<NodeId>> getLabelsToNodes(Set<String> labels) throws YarnException, IOException { return client.getLabelsToNodes(labels); } diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 67c43fbc18934..b3ccc3580ea36 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -205,6 +205,9 @@ Release 2.8.0 - UNRELEASED YARN-3565. NodeHeartbeatRequest/RegisterNodeManagerRequest should use NodeLabel object instead of String. (Naganarasimha G R via wangda) + YARN-3583. Support of NodeLabel object instead of plain String + in YarnClient side. (Sunil G via wangda) + OPTIMIZATIONS YARN-3339. TestDockerContainerExecutor should pull a single image and not diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetLabelsToNodesResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetLabelsToNodesResponse.java index f105359110418..da2be28830e7d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetLabelsToNodesResponse.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetLabelsToNodesResponse.java @@ -24,11 +24,12 @@ import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.util.Records; public abstract class GetLabelsToNodesResponse { public static GetLabelsToNodesResponse newInstance( - Map<String, Set<NodeId>> map) { + Map<NodeLabel, Set<NodeId>> map) { GetLabelsToNodesResponse response = Records.newRecord(GetLabelsToNodesResponse.class); response.setLabelsToNodes(map); @@ -37,9 +38,9 @@ public static GetLabelsToNodesResponse newInstance( @Public @Evolving - public abstract void setLabelsToNodes(Map<String, Set<NodeId>> map); + public abstract void setLabelsToNodes(Map<NodeLabel, Set<NodeId>> map); @Public @Evolving - public abstract Map<String, Set<NodeId>> getLabelsToNodes(); + public abstract Map<NodeLabel, Set<NodeId>> getLabelsToNodes(); } \ No newline at end of file diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetNodesToLabelsResponse.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetNodesToLabelsResponse.java index bcd5421e7ebc3..432485c358aad 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetNodesToLabelsResponse.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/GetNodesToLabelsResponse.java @@ -24,11 +24,12 @@ import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.util.Records; public abstract class GetNodesToLabelsResponse { public static GetNodesToLabelsResponse newInstance( - Map<NodeId, Set<String>> map) { + Map<NodeId, Set<NodeLabel>> map) { GetNodesToLabelsResponse response = Records.newRecord(GetNodesToLabelsResponse.class); response.setNodeToLabels(map); @@ -37,9 +38,9 @@ public static GetNodesToLabelsResponse newInstance( @Public @Evolving - public abstract void setNodeToLabels(Map<NodeId, Set<String>> map); + public abstract void setNodeToLabels(Map<NodeId, Set<NodeLabel>> map); @Public @Evolving - public abstract Map<NodeId, Set<String>> getNodeToLabels(); + public abstract Map<NodeId, Set<NodeLabel>> getNodeToLabels(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/yarn_server_resourcemanager_service_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/yarn_server_resourcemanager_service_protos.proto index d6d8713a247d2..e20b4aea447a3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/yarn_server_resourcemanager_service_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/server/yarn_server_resourcemanager_service_protos.proto @@ -91,7 +91,7 @@ message RemoveFromClusterNodeLabelsResponseProto { } message ReplaceLabelsOnNodeRequestProto { - repeated NodeIdToLabelsProto nodeToLabels = 1; + repeated NodeIdToLabelsNameProto nodeToLabels = 1; } message ReplaceLabelsOnNodeResponseProto { @@ -107,6 +107,11 @@ message CheckForDecommissioningNodesResponseProto { repeated NodeIdProto decommissioningNodes = 1; } +message NodeIdToLabelsNameProto { + optional NodeIdProto nodeId = 1; + repeated string nodeLabels = 2; +} + enum DecommissionTypeProto { NORMAL = 1; GRACEFUL = 2; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto index 3c4aa524c3d9f..b9969b0ef41e6 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto @@ -248,13 +248,13 @@ message NodeReportProto { repeated string node_labels = 10; } -message NodeIdToLabelsProto { +message NodeIdToLabelsInfoProto { optional NodeIdProto nodeId = 1; - repeated string nodeLabels = 2; + repeated NodeLabelProto nodeLabels = 2; } message LabelsToNodeIdsProto { - optional string nodeLabels = 1; + optional NodeLabelProto nodeLabels = 1; repeated NodeIdProto nodeId = 2; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto index 410b66382c1d5..098785aac5e5e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_service_protos.proto @@ -198,7 +198,7 @@ message GetNodesToLabelsRequestProto { } message GetNodesToLabelsResponseProto { - repeated NodeIdToLabelsProto nodeToLabels = 1; + repeated NodeIdToLabelsInfoProto nodeToLabels = 1; } message GetLabelsToNodesRequestProto { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/YarnClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/YarnClient.java index 5ce626c46ab2d..ff03c7d5af763 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/YarnClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/YarnClient.java @@ -619,7 +619,7 @@ public abstract ReservationDeleteResponse deleteReservation( */ @Public @Unstable - public abstract Map<NodeId, Set<String>> getNodeToLabels() + public abstract Map<NodeId, Set<NodeLabel>> getNodeToLabels() throws YarnException, IOException; /** @@ -634,7 +634,7 @@ public abstract Map<NodeId, Set<String>> getNodeToLabels() */ @Public @Unstable - public abstract Map<String, Set<NodeId>> getLabelsToNodes() + public abstract Map<NodeLabel, Set<NodeId>> getLabelsToNodes() throws YarnException, IOException; /** @@ -650,8 +650,8 @@ public abstract Map<String, Set<NodeId>> getLabelsToNodes() */ @Public @Unstable - public abstract Map<String, Set<NodeId>> getLabelsToNodes(Set<String> labels) - throws YarnException, IOException; + public abstract Map<NodeLabel, Set<NodeId>> getLabelsToNodes( + Set<String> labels) throws YarnException, IOException; /** * <p> diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java index 42dd5cdb62328..be4c8c4e1bcde 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java @@ -795,21 +795,21 @@ public ReservationDeleteResponse deleteReservation( } @Override - public Map<NodeId, Set<String>> getNodeToLabels() throws YarnException, + public Map<NodeId, Set<NodeLabel>> getNodeToLabels() throws YarnException, IOException { return rmClient.getNodeToLabels(GetNodesToLabelsRequest.newInstance()) .getNodeToLabels(); } @Override - public Map<String, Set<NodeId>> getLabelsToNodes() throws YarnException, + public Map<NodeLabel, Set<NodeId>> getLabelsToNodes() throws YarnException, IOException { return rmClient.getLabelsToNodes(GetLabelsToNodesRequest.newInstance()) .getLabelsToNodes(); } @Override - public Map<String, Set<NodeId>> getLabelsToNodes(Set<String> labels) + public Map<NodeLabel, Set<NodeId>> getLabelsToNodes(Set<String> labels) throws YarnException, IOException { return rmClient.getLabelsToNodes( GetLabelsToNodesRequest.newInstance(labels)).getLabelsToNodes(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java index 10b9bbbbae6f9..511fa4acb39be 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java @@ -67,6 +67,8 @@ import org.apache.hadoop.yarn.api.protocolrecords.GetContainersResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetLabelsToNodesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetLabelsToNodesResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetNodesToLabelsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetNodesToLabelsResponse; import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest; import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse; import org.apache.hadoop.yarn.api.protocolrecords.ReservationDeleteRequest; @@ -87,6 +89,7 @@ import org.apache.hadoop.yarn.api.records.ContainerState; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.ReservationDefinition; import org.apache.hadoop.yarn.api.records.ReservationId; @@ -458,9 +461,9 @@ public void testGetLabelsToNodes() throws YarnException, IOException { client.start(); // Get labels to nodes mapping - Map<String, Set<NodeId>> expectedLabelsToNodes = + Map<NodeLabel, Set<NodeId>> expectedLabelsToNodes = ((MockYarnClient)client).getLabelsToNodesMap(); - Map<String, Set<NodeId>> labelsToNodes = client.getLabelsToNodes(); + Map<NodeLabel, Set<NodeId>> labelsToNodes = client.getLabelsToNodes(); Assert.assertEquals(labelsToNodes, expectedLabelsToNodes); Assert.assertEquals(labelsToNodes.size(), 3); @@ -476,7 +479,32 @@ public void testGetLabelsToNodes() throws YarnException, IOException { client.close(); } + @Test (timeout = 10000) + public void testGetNodesToLabels() throws YarnException, IOException { + Configuration conf = new Configuration(); + final YarnClient client = new MockYarnClient(); + client.init(conf); + client.start(); + + // Get labels to nodes mapping + Map<NodeId, Set<NodeLabel>> expectedNodesToLabels = ((MockYarnClient) client) + .getNodeToLabelsMap(); + Map<NodeId, Set<NodeLabel>> nodesToLabels = client.getNodeToLabels(); + Assert.assertEquals(nodesToLabels, expectedNodesToLabels); + Assert.assertEquals(nodesToLabels.size(), 1); + + // Verify exclusivity + Set<NodeLabel> labels = nodesToLabels.get(NodeId.newInstance("host", 0)); + for (NodeLabel label : labels) { + Assert.assertFalse(label.isExclusive()); + } + + client.stop(); + client.close(); + } + private static class MockYarnClient extends YarnClientImpl { + private ApplicationReport mockReport; private List<ApplicationReport> reports; private HashMap<ApplicationId, List<ApplicationAttemptReport>> attempts = @@ -498,6 +526,8 @@ private static class MockYarnClient extends YarnClientImpl { mock(GetContainerReportResponse.class); GetLabelsToNodesResponse mockLabelsToNodesResponse = mock(GetLabelsToNodesResponse.class); + GetNodesToLabelsResponse mockNodeToLabelsResponse = + mock(GetNodesToLabelsResponse.class); public MockYarnClient() { super(); @@ -537,6 +567,9 @@ public void start() { when(rmClient.getLabelsToNodes(any(GetLabelsToNodesRequest.class))) .thenReturn(mockLabelsToNodesResponse); + when(rmClient.getNodeToLabels(any(GetNodesToLabelsRequest.class))) + .thenReturn(mockNodeToLabelsResponse); + historyClient = mock(AHSClient.class); } catch (YarnException e) { @@ -704,7 +737,7 @@ private List<ApplicationReport> getApplicationReports( } @Override - public Map<String, Set<NodeId>> getLabelsToNodes() + public Map<NodeLabel, Set<NodeId>> getLabelsToNodes() throws YarnException, IOException { when(mockLabelsToNodesResponse.getLabelsToNodes()).thenReturn( getLabelsToNodesMap()); @@ -712,35 +745,52 @@ public Map<String, Set<NodeId>> getLabelsToNodes() } @Override - public Map<String, Set<NodeId>> getLabelsToNodes(Set<String> labels) + public Map<NodeLabel, Set<NodeId>> getLabelsToNodes(Set<String> labels) throws YarnException, IOException { when(mockLabelsToNodesResponse.getLabelsToNodes()).thenReturn( getLabelsToNodesMap(labels)); return super.getLabelsToNodes(labels); } - public Map<String, Set<NodeId>> getLabelsToNodesMap() { - Map<String, Set<NodeId>> map = new HashMap<String, Set<NodeId>>(); + public Map<NodeLabel, Set<NodeId>> getLabelsToNodesMap() { + Map<NodeLabel, Set<NodeId>> map = new HashMap<NodeLabel, Set<NodeId>>(); Set<NodeId> setNodeIds = new HashSet<NodeId>(Arrays.asList( NodeId.newInstance("host1", 0), NodeId.newInstance("host2", 0))); - map.put("x", setNodeIds); - map.put("y", setNodeIds); - map.put("z", setNodeIds); + map.put(NodeLabel.newInstance("x"), setNodeIds); + map.put(NodeLabel.newInstance("y"), setNodeIds); + map.put(NodeLabel.newInstance("z"), setNodeIds); return map; } - public Map<String, Set<NodeId>> getLabelsToNodesMap(Set<String> labels) { - Map<String, Set<NodeId>> map = new HashMap<String, Set<NodeId>>(); + public Map<NodeLabel, Set<NodeId>> getLabelsToNodesMap(Set<String> labels) { + Map<NodeLabel, Set<NodeId>> map = new HashMap<NodeLabel, Set<NodeId>>(); Set<NodeId> setNodeIds = new HashSet<NodeId>(Arrays.asList( NodeId.newInstance("host1", 0), NodeId.newInstance("host2", 0))); for(String label : labels) { - map.put(label, setNodeIds); + map.put(NodeLabel.newInstance(label), setNodeIds); } return map; } + @Override + public Map<NodeId, Set<NodeLabel>> getNodeToLabels() throws YarnException, + IOException { + when(mockNodeToLabelsResponse.getNodeToLabels()).thenReturn( + getNodeToLabelsMap()); + return super.getNodeToLabels(); + } + + public Map<NodeId, Set<NodeLabel>> getNodeToLabelsMap() { + Map<NodeId, Set<NodeLabel>> map = new HashMap<NodeId, Set<NodeLabel>>(); + Set<NodeLabel> setNodeLabels = new HashSet<NodeLabel>(Arrays.asList( + NodeLabel.newInstance("x", false), + NodeLabel.newInstance("y", false))); + map.put(NodeId.newInstance("host", 0), setNodeLabels); + return map; + } + @Override public List<ApplicationAttemptReport> getApplicationAttempts( ApplicationId appId) throws YarnException, IOException { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetLabelsToNodesResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetLabelsToNodesResponsePBImpl.java index e1979973320c4..418fcbd4cc6f8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetLabelsToNodesResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetLabelsToNodesResponsePBImpl.java @@ -29,11 +29,13 @@ import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.NodeLabelPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; import org.apache.hadoop.yarn.api.protocolrecords.GetLabelsToNodesResponse; - import org.apache.hadoop.yarn.proto.YarnProtos.LabelsToNodeIdsProto; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetLabelsToNodesResponseProtoOrBuilder; @@ -44,7 +46,7 @@ public class GetLabelsToNodesResponsePBImpl extends GetLabelsToNodesResponseProto.Builder builder = null; boolean viaProto = false; - private Map<String, Set<NodeId>> labelsToNodes; + private Map<NodeLabel, Set<NodeId>> labelsToNodes; public GetLabelsToNodesResponsePBImpl() { this.builder = GetLabelsToNodesResponseProto.newBuilder(); @@ -61,7 +63,7 @@ private void initLabelsToNodes() { } GetLabelsToNodesResponseProtoOrBuilder p = viaProto ? proto : builder; List<LabelsToNodeIdsProto> list = p.getLabelsToNodesList(); - this.labelsToNodes = new HashMap<String, Set<NodeId>>(); + this.labelsToNodes = new HashMap<NodeLabel, Set<NodeId>>(); for (LabelsToNodeIdsProto c : list) { Set<NodeId> setNodes = new HashSet<NodeId>(); @@ -69,8 +71,9 @@ private void initLabelsToNodes() { NodeId node = new NodeIdPBImpl(n); setNodes.add(node); } - if(!setNodes.isEmpty()) { - this.labelsToNodes.put(c.getNodeLabels(), setNodes); + if (!setNodes.isEmpty()) { + this.labelsToNodes + .put(new NodeLabelPBImpl(c.getNodeLabels()), setNodes); } } } @@ -94,7 +97,7 @@ private void addLabelsToNodesToProto() { public Iterator<LabelsToNodeIdsProto> iterator() { return new Iterator<LabelsToNodeIdsProto>() { - Iterator<Entry<String, Set<NodeId>>> iter = + Iterator<Entry<NodeLabel, Set<NodeId>>> iter = labelsToNodes.entrySet().iterator(); @Override @@ -104,13 +107,14 @@ public void remove() { @Override public LabelsToNodeIdsProto next() { - Entry<String, Set<NodeId>> now = iter.next(); + Entry<NodeLabel, Set<NodeId>> now = iter.next(); Set<NodeIdProto> nodeProtoSet = new HashSet<NodeIdProto>(); for(NodeId n : now.getValue()) { nodeProtoSet.add(convertToProtoFormat(n)); } return LabelsToNodeIdsProto.newBuilder() - .setNodeLabels(now.getKey()).addAllNodeId(nodeProtoSet) + .setNodeLabels(convertToProtoFormat(now.getKey())) + .addAllNodeId(nodeProtoSet) .build(); } @@ -149,6 +153,10 @@ private NodeIdProto convertToProtoFormat(NodeId t) { return ((NodeIdPBImpl)t).getProto(); } + private NodeLabelProto convertToProtoFormat(NodeLabel l) { + return ((NodeLabelPBImpl)l).getProto(); + } + @Override public int hashCode() { assert false : "hashCode not designed"; @@ -168,7 +176,7 @@ public boolean equals(Object other) { @Override @Public @Evolving - public void setLabelsToNodes(Map<String, Set<NodeId>> map) { + public void setLabelsToNodes(Map<NodeLabel, Set<NodeId>> map) { initLabelsToNodes(); labelsToNodes.clear(); labelsToNodes.putAll(map); @@ -177,7 +185,7 @@ public void setLabelsToNodes(Map<String, Set<NodeId>> map) { @Override @Public @Evolving - public Map<String, Set<NodeId>> getLabelsToNodes() { + public Map<NodeLabel, Set<NodeId>> getLabelsToNodes() { initLabelsToNodes(); return this.labelsToNodes; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNodesToLabelsResponsePBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNodesToLabelsResponsePBImpl.java index 340483008032c..52be73f6a4b9e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNodesToLabelsResponsePBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/api/protocolrecords/impl/pb/GetNodesToLabelsResponsePBImpl.java @@ -19,6 +19,7 @@ package org.apache.hadoop.yarn.api.protocolrecords.impl.pb; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -26,12 +27,13 @@ import java.util.Set; import org.apache.hadoop.yarn.api.records.NodeId; +import org.apache.hadoop.yarn.api.records.NodeLabel; import org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl; +import org.apache.hadoop.yarn.api.records.impl.pb.NodeLabelPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; import org.apache.hadoop.yarn.api.protocolrecords.GetNodesToLabelsResponse; - -import com.google.common.collect.Sets; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdToLabelsProto; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdToLabelsInfoProto; +import org.apache.hadoop.yarn.proto.YarnProtos.NodeLabelProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNodesToLabelsResponseProto; import org.apache.hadoop.yarn.proto.YarnServiceProtos.GetNodesToLabelsResponseProtoOrBuilder; @@ -42,8 +44,8 @@ public class GetNodesToLabelsResponsePBImpl extends GetNodesToLabelsResponseProto.Builder builder = null; boolean viaProto = false; - private Map<NodeId, Set<String>> nodeToLabels; - + private Map<NodeId, Set<NodeLabel>> nodeToLabels; + public GetNodesToLabelsResponsePBImpl() { this.builder = GetNodesToLabelsResponseProto.newBuilder(); } @@ -58,12 +60,15 @@ private void initNodeToLabels() { return; } GetNodesToLabelsResponseProtoOrBuilder p = viaProto ? proto : builder; - List<NodeIdToLabelsProto> list = p.getNodeToLabelsList(); - this.nodeToLabels = new HashMap<NodeId, Set<String>>(); - - for (NodeIdToLabelsProto c : list) { - this.nodeToLabels.put(new NodeIdPBImpl(c.getNodeId()), - Sets.newHashSet(c.getNodeLabelsList())); + List<NodeIdToLabelsInfoProto> list = p.getNodeToLabelsList(); + this.nodeToLabels = new HashMap<NodeId, Set<NodeLabel>>(); + + for (NodeIdToLabelsInfoProto c : list) { + Set<NodeLabel> labels = new HashSet<NodeLabel>(); + for (NodeLabelProto l : c.getNodeLabelsList()) { + labels.add(new NodeLabelPBImpl(l)); + } + this.nodeToLabels.put(new NodeIdPBImpl(c.getNodeId()), labels); } } @@ -80,13 +85,13 @@ private void addNodeToLabelsToProto() { if (nodeToLabels == null) { return; } - Iterable<NodeIdToLabelsProto> iterable = - new Iterable<NodeIdToLabelsProto>() { + Iterable<NodeIdToLabelsInfoProto> iterable = + new Iterable<NodeIdToLabelsInfoProto>() { @Override - public Iterator<NodeIdToLabelsProto> iterator() { - return new Iterator<NodeIdToLabelsProto>() { + public Iterator<NodeIdToLabelsInfoProto> iterator() { + return new Iterator<NodeIdToLabelsInfoProto>() { - Iterator<Entry<NodeId, Set<String>>> iter = nodeToLabels + Iterator<Entry<NodeId, Set<NodeLabel>>> iter = nodeToLabels .entrySet().iterator(); @Override @@ -95,11 +100,16 @@ public void remove() { } @Override - public NodeIdToLabelsProto next() { - Entry<NodeId, Set<String>> now = iter.next(); - return NodeIdToLabelsProto.newBuilder() + public NodeIdToLabelsInfoProto next() { + Entry<NodeId, Set<NodeLabel>> now = iter.next(); + Set<NodeLabelProto> labelProtoList = + new HashSet<NodeLabelProto>(); + for (NodeLabel l : now.getValue()) { + labelProtoList.add(convertToProtoFormat(l)); + } + return NodeIdToLabelsInfoProto.newBuilder() .setNodeId(convertToProtoFormat(now.getKey())) - .addAllNodeLabels(now.getValue()).build(); + .addAllNodeLabels(labelProtoList).build(); } @Override @@ -134,13 +144,13 @@ public GetNodesToLabelsResponseProto getProto() { } @Override - public Map<NodeId, Set<String>> getNodeToLabels() { + public Map<NodeId, Set<NodeLabel>> getNodeToLabels() { initNodeToLabels(); return this.nodeToLabels; } @Override - public void setNodeToLabels(Map<NodeId, Set<String>> map) { + public void setNodeToLabels(Map<NodeId, Set<NodeLabel>> map) { initNodeToLabels(); nodeToLabels.clear(); nodeToLabels.putAll(map); @@ -150,6 +160,10 @@ private NodeIdProto convertToProtoFormat(NodeId t) { return ((NodeIdPBImpl)t).getProto(); } + private NodeLabelProto convertToProtoFormat(NodeLabel t) { + return ((NodeLabelPBImpl)t).getProto(); + } + @Override public int hashCode() { assert false : "hashCode not designed"; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/ReplaceLabelsOnNodeRequestPBImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/ReplaceLabelsOnNodeRequestPBImpl.java index e296aaf13b8b0..22e561cd94a7a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/ReplaceLabelsOnNodeRequestPBImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/server/api/protocolrecords/impl/pb/ReplaceLabelsOnNodeRequestPBImpl.java @@ -28,7 +28,7 @@ import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl; import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto; -import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdToLabelsProto; +import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.NodeIdToLabelsNameProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.ReplaceLabelsOnNodeRequestProto; import org.apache.hadoop.yarn.proto.YarnServerResourceManagerServiceProtos.ReplaceLabelsOnNodeRequestProtoOrBuilder; import org.apache.hadoop.yarn.server.api.protocolrecords.ReplaceLabelsOnNodeRequest; @@ -58,10 +58,10 @@ private void initNodeToLabels() { return; } ReplaceLabelsOnNodeRequestProtoOrBuilder p = viaProto ? proto : builder; - List<NodeIdToLabelsProto> list = p.getNodeToLabelsList(); + List<NodeIdToLabelsNameProto> list = p.getNodeToLabelsList(); this.nodeIdToLabels = new HashMap<NodeId, Set<String>>(); - for (NodeIdToLabelsProto c : list) { + for (NodeIdToLabelsNameProto c : list) { this.nodeIdToLabels.put(new NodeIdPBImpl(c.getNodeId()), Sets.newHashSet(c.getNodeLabelsList())); } @@ -80,11 +80,11 @@ private void addNodeToLabelsToProto() { if (nodeIdToLabels == null) { return; } - Iterable<NodeIdToLabelsProto> iterable = - new Iterable<NodeIdToLabelsProto>() { + Iterable<NodeIdToLabelsNameProto> iterable = + new Iterable<NodeIdToLabelsNameProto>() { @Override - public Iterator<NodeIdToLabelsProto> iterator() { - return new Iterator<NodeIdToLabelsProto>() { + public Iterator<NodeIdToLabelsNameProto> iterator() { + return new Iterator<NodeIdToLabelsNameProto>() { Iterator<Entry<NodeId, Set<String>>> iter = nodeIdToLabels .entrySet().iterator(); @@ -95,9 +95,9 @@ public void remove() { } @Override - public NodeIdToLabelsProto next() { + public NodeIdToLabelsNameProto next() { Entry<NodeId, Set<String>> now = iter.next(); - return NodeIdToLabelsProto.newBuilder() + return NodeIdToLabelsNameProto.newBuilder() .setNodeId(convertToProtoFormat(now.getKey())).clearNodeLabels() .addAllNodeLabels(now.getValue()).build(); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java index b927b47fb70f7..0ef43888dabf2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/ClientRMService.java @@ -1226,7 +1226,7 @@ public GetNodesToLabelsResponse getNodeToLabels( GetNodesToLabelsRequest request) throws YarnException, IOException { RMNodeLabelsManager labelsMgr = rmContext.getNodeLabelManager(); GetNodesToLabelsResponse response = - GetNodesToLabelsResponse.newInstance(labelsMgr.getNodeLabels()); + GetNodesToLabelsResponse.newInstance(labelsMgr.getNodeLabelsInfo()); return response; } @@ -1236,10 +1236,10 @@ public GetLabelsToNodesResponse getLabelsToNodes( RMNodeLabelsManager labelsMgr = rmContext.getNodeLabelManager(); if (request.getNodeLabels() == null || request.getNodeLabels().isEmpty()) { return GetLabelsToNodesResponse.newInstance( - labelsMgr.getLabelsToNodes()); + labelsMgr.getLabelsInfoToNodes()); } else { return GetLabelsToNodesResponse.newInstance( - labelsMgr.getLabelsToNodes(request.getNodeLabels())); + labelsMgr.getLabelsInfoToNodes(request.getNodeLabels())); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java index a39f94f07a243..20343a51856cd 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java @@ -1407,8 +1407,10 @@ protected ClientRMService createClientRMService() { }; }; rm.start(); + NodeLabel labelX = NodeLabel.newInstance("x", false); + NodeLabel labelY = NodeLabel.newInstance("y"); RMNodeLabelsManager labelsMgr = rm.getRMContext().getNodeLabelManager(); - labelsMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y")); + labelsMgr.addToCluserNodeLabels(ImmutableSet.of(labelX, labelY)); NodeId node1 = NodeId.newInstance("host1", 1234); NodeId node2 = NodeId.newInstance("host2", 1234); @@ -1422,25 +1424,37 @@ protected ClientRMService createClientRMService() { YarnRPC rpc = YarnRPC.create(conf); InetSocketAddress rmAddress = rm.getClientRMService().getBindAddress(); LOG.info("Connecting to ResourceManager at " + rmAddress); - ApplicationClientProtocol client = - (ApplicationClientProtocol) rpc.getProxy( - ApplicationClientProtocol.class, rmAddress, conf); + ApplicationClientProtocol client = (ApplicationClientProtocol) rpc + .getProxy(ApplicationClientProtocol.class, rmAddress, conf); // Get node labels collection - GetClusterNodeLabelsResponse response = - client.getClusterNodeLabels(GetClusterNodeLabelsRequest.newInstance()); + GetClusterNodeLabelsResponse response = client + .getClusterNodeLabels(GetClusterNodeLabelsRequest.newInstance()); Assert.assertTrue(response.getNodeLabels().containsAll( - Arrays.asList(NodeLabel.newInstance("x"), NodeLabel.newInstance("y")))); + Arrays.asList(labelX, labelY))); // Get node labels mapping - GetNodesToLabelsResponse response1 = - client.getNodeToLabels(GetNodesToLabelsRequest.newInstance()); - Map<NodeId, Set<String>> nodeToLabels = response1.getNodeToLabels(); + GetNodesToLabelsResponse response1 = client + .getNodeToLabels(GetNodesToLabelsRequest.newInstance()); + Map<NodeId, Set<NodeLabel>> nodeToLabels = response1.getNodeToLabels(); Assert.assertTrue(nodeToLabels.keySet().containsAll( Arrays.asList(node1, node2))); - Assert.assertTrue(nodeToLabels.get(node1).containsAll(Arrays.asList("x"))); - Assert.assertTrue(nodeToLabels.get(node2).containsAll(Arrays.asList("y"))); - + Assert.assertTrue(nodeToLabels.get(node1) + .containsAll(Arrays.asList(labelX))); + Assert.assertTrue(nodeToLabels.get(node2) + .containsAll(Arrays.asList(labelY))); + // Verify whether labelX's exclusivity is false + for (NodeLabel x : nodeToLabels.get(node1)) { + Assert.assertFalse(x.isExclusive()); + } + // Verify whether labelY's exclusivity is true + for (NodeLabel y : nodeToLabels.get(node2)) { + Assert.assertTrue(y.isExclusive()); + } + // Below label "x" is not present in the response as exclusivity is true + Assert.assertFalse(nodeToLabels.get(node1).containsAll( + Arrays.asList(NodeLabel.newInstance("x")))); + rpc.stopProxy(client, conf); rm.close(); } @@ -1456,8 +1470,12 @@ protected ClientRMService createClientRMService() { }; }; rm.start(); + + NodeLabel labelX = NodeLabel.newInstance("x", false); + NodeLabel labelY = NodeLabel.newInstance("y", false); + NodeLabel labelZ = NodeLabel.newInstance("z", false); RMNodeLabelsManager labelsMgr = rm.getRMContext().getNodeLabelManager(); - labelsMgr.addToCluserNodeLabelsWithDefaultExclusivity(ImmutableSet.of("x", "y", "z")); + labelsMgr.addToCluserNodeLabels(ImmutableSet.of(labelX, labelY, labelZ)); NodeId node1A = NodeId.newInstance("host1", 1234); NodeId node1B = NodeId.newInstance("host1", 5678); @@ -1477,43 +1495,49 @@ protected ClientRMService createClientRMService() { YarnRPC rpc = YarnRPC.create(conf); InetSocketAddress rmAddress = rm.getClientRMService().getBindAddress(); LOG.info("Connecting to ResourceManager at " + rmAddress); - ApplicationClientProtocol client = - (ApplicationClientProtocol) rpc.getProxy( - ApplicationClientProtocol.class, rmAddress, conf); + ApplicationClientProtocol client = (ApplicationClientProtocol) rpc + .getProxy(ApplicationClientProtocol.class, rmAddress, conf); // Get node labels collection - GetClusterNodeLabelsResponse response = - client.getClusterNodeLabels(GetClusterNodeLabelsRequest.newInstance()); + GetClusterNodeLabelsResponse response = client + .getClusterNodeLabels(GetClusterNodeLabelsRequest.newInstance()); Assert.assertTrue(response.getNodeLabels().containsAll( - Arrays.asList(NodeLabel.newInstance("x"), NodeLabel.newInstance("y"), - NodeLabel.newInstance("z")))); + Arrays.asList(labelX, labelY, labelZ))); // Get labels to nodes mapping - GetLabelsToNodesResponse response1 = - client.getLabelsToNodes(GetLabelsToNodesRequest.newInstance()); - Map<String, Set<NodeId>> labelsToNodes = response1.getLabelsToNodes(); - Assert.assertTrue( - labelsToNodes.keySet().containsAll(Arrays.asList("x", "y", "z"))); - Assert.assertTrue( - labelsToNodes.get("x").containsAll(Arrays.asList(node1A))); - Assert.assertTrue( - labelsToNodes.get("y").containsAll(Arrays.asList(node2A, node3A))); - Assert.assertTrue( - labelsToNodes.get("z").containsAll(Arrays.asList(node1B, node3B))); + GetLabelsToNodesResponse response1 = client + .getLabelsToNodes(GetLabelsToNodesRequest.newInstance()); + Map<NodeLabel, Set<NodeId>> labelsToNodes = response1.getLabelsToNodes(); + // Verify whether all NodeLabel's exclusivity are false + for (Map.Entry<NodeLabel, Set<NodeId>> nltn : labelsToNodes.entrySet()) { + Assert.assertFalse(nltn.getKey().isExclusive()); + } + Assert.assertTrue(labelsToNodes.keySet().containsAll( + Arrays.asList(labelX, labelY, labelZ))); + Assert.assertTrue(labelsToNodes.get(labelX).containsAll( + Arrays.asList(node1A))); + Assert.assertTrue(labelsToNodes.get(labelY).containsAll( + Arrays.asList(node2A, node3A))); + Assert.assertTrue(labelsToNodes.get(labelZ).containsAll( + Arrays.asList(node1B, node3B))); // Get labels to nodes mapping for specific labels - Set<String> setlabels = - new HashSet<String>(Arrays.asList(new String[]{"x", "z"})); - GetLabelsToNodesResponse response2 = - client.getLabelsToNodes(GetLabelsToNodesRequest.newInstance(setlabels)); + Set<String> setlabels = new HashSet<String>(Arrays.asList(new String[]{"x", + "z"})); + GetLabelsToNodesResponse response2 = client + .getLabelsToNodes(GetLabelsToNodesRequest.newInstance(setlabels)); labelsToNodes = response2.getLabelsToNodes(); - Assert.assertTrue( - labelsToNodes.keySet().containsAll(Arrays.asList("x", "z"))); - Assert.assertTrue( - labelsToNodes.get("x").containsAll(Arrays.asList(node1A))); - Assert.assertTrue( - labelsToNodes.get("z").containsAll(Arrays.asList(node1B, node3B))); - Assert.assertEquals(labelsToNodes.get("y"), null); + // Verify whether all NodeLabel's exclusivity are false + for (Map.Entry<NodeLabel, Set<NodeId>> nltn : labelsToNodes.entrySet()) { + Assert.assertFalse(nltn.getKey().isExclusive()); + } + Assert.assertTrue(labelsToNodes.keySet().containsAll( + Arrays.asList(labelX, labelZ))); + Assert.assertTrue(labelsToNodes.get(labelX).containsAll( + Arrays.asList(node1A))); + Assert.assertTrue(labelsToNodes.get(labelZ).containsAll( + Arrays.asList(node1B, node3B))); + Assert.assertEquals(labelsToNodes.get(labelY), null); rpc.stopProxy(client, conf); rm.close();
c512c4594c95d08edf0a63cb30ed643a4ed69fcc
drools
[JBRULES-3668] format and shorten kproject.xml file--
p
https://github.com/kiegroup/drools
diff --git a/drools-compiler/src/main/java/org/drools/cdi/KProjectExtension.java b/drools-compiler/src/main/java/org/drools/cdi/KProjectExtension.java index 5bc78adf1fd..1e7ddc2d3bd 100644 --- a/drools-compiler/src/main/java/org/drools/cdi/KProjectExtension.java +++ b/drools-compiler/src/main/java/org/drools/cdi/KProjectExtension.java @@ -33,6 +33,7 @@ import org.drools.kproject.KBaseImpl; import org.drools.kproject.KProject; +import org.drools.kproject.KProjectImpl; import org.drools.kproject.KSessionImpl; import org.kie.KnowledgeBase; import org.kie.KnowledgeBaseFactory; @@ -473,8 +474,7 @@ public void buildKProjects() { while ( e.hasMoreElements() ) { URL url = e.nextElement();; try { - XStream xstream = new XStream(); - KProject kProject = (KProject) xstream.fromXML( url ); + KProject kProject = KProjectImpl.fromXML(url); String kProjectId = kProject.getGroupArtifactVersion().getGroupId() + ":" + kProject.getGroupArtifactVersion().getArtifactId(); urls.put( kProjectId, fixURL( url ) ); kProjects.put( kProjectId, kProject ); diff --git a/drools-compiler/src/main/java/org/drools/kproject/KBaseImpl.java b/drools-compiler/src/main/java/org/drools/kproject/KBaseImpl.java index 4a75bcb012c..85d915f492d 100644 --- a/drools-compiler/src/main/java/org/drools/kproject/KBaseImpl.java +++ b/drools-compiler/src/main/java/org/drools/kproject/KBaseImpl.java @@ -10,9 +10,14 @@ import java.util.Map; import java.util.Set; -import org.drools.RuleBaseConfiguration.AssertBehaviour; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.drools.core.util.AbstractXStreamConverter; import org.kie.conf.AssertBehaviorOption; import org.kie.conf.EventProcessingOption; +import org.kie.runtime.conf.ClockTypeOption; public class KBaseImpl implements @@ -37,6 +42,11 @@ public class KBaseImpl private transient PropertyChangeListener listener; + private KBaseImpl() { + this.includes = new HashSet<String>(); + this.files = new ArrayList<String>(); + } + public KBaseImpl(KProjectImpl kProject, String namespace, String name) { @@ -267,4 +277,60 @@ public String toString() { return "KBase [namespace=" + namespace + ", name=" + name + ", files=" + files + ", annotations=" + annotations + ", equalsBehaviour=" + equalsBehavior + ", eventProcessingMode=" + eventProcessingMode + ", ksessions=" + kSessions + "]"; } + public static class KBaseConverter extends AbstractXStreamConverter { + + public KBaseConverter() { + super(KBaseImpl.class); + } + + public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { + KBaseImpl kBase = (KBaseImpl) value; + writer.addAttribute("name", kBase.getName()); + writer.addAttribute("namespace", kBase.getNamespace()); + if (kBase.getEventProcessingMode() != null) { + writer.addAttribute("eventProcessingMode", kBase.getEventProcessingMode().getMode()); + } + if (kBase.getEqualsBehavior() != null) { + writer.addAttribute("equalsBehavior", kBase.getEqualsBehavior().toString()); + } + writeList(writer, "files", "file", kBase.getFiles()); + writeList(writer, "includes", "include", kBase.getIncludes()); + writeObjectList(writer, context, "ksessions", "ksession", kBase.getKSessions().values()); + } + + public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context) { + final KBaseImpl kBase = new KBaseImpl(); + kBase.setName(reader.getAttribute("name")); + kBase.setNamespace(reader.getAttribute("namespace")); + + String eventMode = reader.getAttribute("eventProcessingMode"); + if (eventMode != null) { + kBase.setEventProcessingMode(EventProcessingOption.determineEventProcessingMode(eventMode)); + } + String equalsBehavior = reader.getAttribute("equalsBehavior"); + if (equalsBehavior != null) { + kBase.setEqualsBehavior(AssertBehaviorOption.valueOf(equalsBehavior)); + } + + readNodes(reader, new AbstractXStreamConverter.NodeReader() { + public void onNode(HierarchicalStreamReader reader, String name, String value) { + if ("ksessions".equals(name)) { + Map<String, KSession> kSessions = new HashMap<String, KSession>(); + for (KSessionImpl kSession : readObjectList(reader, context, KSessionImpl.class)) { + kSession.setKBase(kBase); + kSessions.put( kSession.getQName(), kSession ); + } + kBase.setKSessions(kSessions); + } else if ("files".equals(name)) { + kBase.setFiles(readList(reader)); + } else if ("includes".equals(name)) { + for (String include : readList(reader)) { + kBase.addInclude(include); + } + } + } + }); + return kBase; + } + } } diff --git a/drools-compiler/src/main/java/org/drools/kproject/KProjectImpl.java b/drools-compiler/src/main/java/org/drools/kproject/KProjectImpl.java index fcb73c87302..a02ab1516ff 100644 --- a/drools-compiler/src/main/java/org/drools/kproject/KProjectImpl.java +++ b/drools-compiler/src/main/java/org/drools/kproject/KProjectImpl.java @@ -1,6 +1,14 @@ package org.drools.kproject; import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import com.thoughtworks.xstream.io.xml.DomDriver; +import org.drools.core.util.AbstractXStreamConverter; +import org.kie.conf.AssertBehaviorOption; +import org.kie.conf.EventProcessingOption; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -177,18 +185,87 @@ public String toString() { } public String toXML() { - return new XStream().toXML(this); + return MARSHALLER.toXML(this); } public static KProject fromXML(InputStream kProjectStream) { - return (KProject)new XStream().fromXML(kProjectStream); + return MARSHALLER.fromXML(kProjectStream); } public static KProject fromXML(java.io.File kProjectFile) { - return (KProject)new XStream().fromXML(kProjectFile); + return MARSHALLER.fromXML(kProjectFile); } public static KProject fromXML(URL kProjectUrl) { - return (KProject)new XStream().fromXML(kProjectUrl); + return MARSHALLER.fromXML(kProjectUrl); } -} + + private static final KProjectMarshaller MARSHALLER = new KProjectMarshaller(); + + private static class KProjectMarshaller { + private final XStream xStream = new XStream(new DomDriver()); + + private KProjectMarshaller() { + xStream.registerConverter(new KProjectConverter()); + xStream.registerConverter(new KBaseImpl.KBaseConverter()); + xStream.registerConverter(new KSessionImpl.KSessionConverter()); + xStream.alias("kproject", KProjectImpl.class); + xStream.alias("kbase", KBaseImpl.class); + xStream.alias("ksession", KSessionImpl.class); + } + + public String toXML(KProject kProject) { + return xStream.toXML(kProject); + } + + public KProject fromXML(InputStream kProjectStream) { + return (KProject)xStream.fromXML(kProjectStream); + } + + public KProject fromXML(java.io.File kProjectFile) { + return (KProject)xStream.fromXML(kProjectFile); + } + + public KProject fromXML(URL kProjectUrl) { + return (KProject)xStream.fromXML(kProjectUrl); + } + } + + public static class KProjectConverter extends AbstractXStreamConverter { + + public KProjectConverter() { + super(KProjectImpl.class); + } + + public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { + KProjectImpl kProject = (KProjectImpl) value; + writeAttribute(writer, "kBasesPath", kProject.getKBasesPath()); + writeAttribute(writer, "kProjectPath", kProject.getKProjectPath()); + writeObject(writer, context, "groupArtifactVersion", kProject.getGroupArtifactVersion()); + writeObjectList(writer, context, "kbases", "kbase", kProject.getKBases().values()); + } + + public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingContext context) { + final KProjectImpl kProject = new KProjectImpl(); + kProject.setKBasesPath(reader.getAttribute("kBasesPath")); + kProject.setKProjectPath(reader.getAttribute("kProjectPath")); + + readNodes(reader, new AbstractXStreamConverter.NodeReader() { + public void onNode(HierarchicalStreamReader reader, String name, String value) { + if ("groupArtifactVersion".equals(name)) { + kProject.setGroupArtifactVersion((GroupArtifactVersion) context.convertAnother(reader.getValue(), GroupArtifactVersion.class)); + } else if ("kbases".equals(name)) { + Map<String, KBase> kBases = new HashMap<String, KBase>(); + for (KBaseImpl kBase : readObjectList(reader, context, KBaseImpl.class)) { + kBase.setKProject(kProject); + kBases.put(kBase.getQName(), kBase); + } + kProject.setKBases(kBases); + } + } + }); + + return kProject; + } + } +} \ No newline at end of file diff --git a/drools-compiler/src/main/java/org/drools/kproject/KSessionImpl.java b/drools-compiler/src/main/java/org/drools/kproject/KSessionImpl.java index d9548f7aeea..d43f11163ea 100644 --- a/drools-compiler/src/main/java/org/drools/kproject/KSessionImpl.java +++ b/drools-compiler/src/main/java/org/drools/kproject/KSessionImpl.java @@ -1,13 +1,18 @@ package org.drools.kproject; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.drools.core.util.AbstractXStreamConverter; +import org.kie.conf.AssertBehaviorOption; +import org.kie.runtime.conf.ClockTypeOption; + import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; import java.util.List; -import org.drools.ClockType; -import org.kie.runtime.conf.ClockTypeOption; - public class KSessionImpl implements KSession { @@ -23,6 +28,8 @@ public class KSessionImpl private transient PropertyChangeListener listener; + private KSessionImpl() { } + public KSessionImpl(KBaseImpl kBase, String namespace, String name) { @@ -157,4 +164,33 @@ public String toString() { return "KSession [namespace=" + namespace + ", name=" + name + ", clockType=" + clockType + ", annotations=" + annotations + "]"; } -} + public static class KSessionConverter extends AbstractXStreamConverter { + + public KSessionConverter() { + super(KSessionImpl.class); + } + + public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { + KSessionImpl kSession = (KSessionImpl) value; + writer.addAttribute("name", kSession.getName()); + writer.addAttribute("namespace", kSession.getNamespace()); + writer.addAttribute("type", kSession.getType()); + if (kSession.getClockType() != null) { + writer.addAttribute("clockType", kSession.getClockType().getClockType()); + } + } + + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { + KSessionImpl kSession = new KSessionImpl(); + kSession.setName(reader.getAttribute("name")); + kSession.setNamespace(reader.getAttribute("namespace")); + kSession.setType(reader.getAttribute("type")); + + String clockType = reader.getAttribute("clockType"); + if (clockType != null) { + kSession.setClockType(ClockTypeOption.get(clockType)); + } + return kSession; + } + } +} \ No newline at end of file diff --git a/drools-compiler/src/test/java/org/drools/kproject/AbstractKnowledgeTest.java b/drools-compiler/src/test/java/org/drools/kproject/AbstractKnowledgeTest.java index 2491b71b265..01476f07b4a 100644 --- a/drools-compiler/src/test/java/org/drools/kproject/AbstractKnowledgeTest.java +++ b/drools-compiler/src/test/java/org/drools/kproject/AbstractKnowledgeTest.java @@ -102,9 +102,8 @@ public void createKProjectJar(String namespace, File fle2 = fld2.getFile( "beans.xml" ); fle2.create( new ByteArrayInputStream( generateBeansXML( kproj ).getBytes() ) ); - XStream xstream = new XStream(); fle2 = fld2.getFile( "kproject.xml" ); - fle2.create( new ByteArrayInputStream( xstream.toXML( kproj ).getBytes() ) ); + fle2.create( new ByteArrayInputStream( ((KProjectImpl)kproj).toXML().getBytes() ) ); String kBase1R1 = getRule( namespace + ".test1", "rule1" ); String kBase1R2 = getRule( namespace + ".test1", "rule2" ); diff --git a/drools-compiler/src/test/java/org/drools/kproject/KJarTest.java b/drools-compiler/src/test/java/org/drools/kproject/KJarTest.java index 04d7e403c70..08ecb7ccb12 100644 --- a/drools-compiler/src/test/java/org/drools/kproject/KJarTest.java +++ b/drools-compiler/src/test/java/org/drools/kproject/KJarTest.java @@ -113,8 +113,7 @@ private void createKJar() throws IOException { .setAnnotations( asList( "@ApplicationScoped; @Inject" ) ) .setClockType( ClockTypeOption.get("realtime") ); - XStream xstream = new XStream(); - fileManager.write(fileManager.newFile(KnowledgeContainerImpl.KPROJECT_RELATIVE_PATH), xstream.toXML( kproj )); + fileManager.write( fileManager.newFile(KnowledgeContainerImpl.KPROJECT_RELATIVE_PATH), ((KProjectImpl)kproj).toXML() ); KnowledgeContainer kcontainer = KnowledgeBuilderFactory.newKnowledgeContainer(); diff --git a/drools-compiler/src/test/java/org/drools/kproject/KnowledgeContainerTest.java b/drools-compiler/src/test/java/org/drools/kproject/KnowledgeContainerTest.java index 51545347550..d55c02a3bcd 100644 --- a/drools-compiler/src/test/java/org/drools/kproject/KnowledgeContainerTest.java +++ b/drools-compiler/src/test/java/org/drools/kproject/KnowledgeContainerTest.java @@ -104,7 +104,7 @@ private File createKJar(KnowledgeContainer kContainer, String kjarName, String.. .setAnnotations( asList( "@ApplicationScoped; @Inject" ) ) .setClockType( ClockTypeOption.get("realtime") ); - fileManager.write(fileManager.newFile(KnowledgeContainerImpl.KPROJECT_RELATIVE_PATH), new XStream().toXML(kproj)); + fileManager.write(fileManager.newFile(KnowledgeContainerImpl.KPROJECT_RELATIVE_PATH), ((KProjectImpl)kproj).toXML() ); return kContainer.buildKJar(fileManager.getRootDirectory(), fileManager.getRootDirectory(), kjarName); } diff --git a/drools-core/src/main/java/org/drools/core/util/AbstractXStreamConverter.java b/drools-core/src/main/java/org/drools/core/util/AbstractXStreamConverter.java new file mode 100644 index 00000000000..b129d5e7ac6 --- /dev/null +++ b/drools-core/src/main/java/org/drools/core/util/AbstractXStreamConverter.java @@ -0,0 +1,105 @@ +package org.drools.core.util; + +import com.thoughtworks.xstream.converters.Converter; +import com.thoughtworks.xstream.converters.MarshallingContext; +import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; + +import java.util.*; + +public abstract class AbstractXStreamConverter implements Converter { + private final Class type; + + protected AbstractXStreamConverter(Class type) { + this.type = type; + } + + public boolean canConvert(Class clazz) { + return type.isAssignableFrom(clazz); + } + + protected void writeAttribute(HierarchicalStreamWriter writer, String name, String value) { + if (value != null) { + writer.addAttribute(name, value); + } + } + + protected void writeString(HierarchicalStreamWriter writer, String name, String value) { + if (value != null) { + writer.startNode(name); + writer.setValue(value); + writer.endNode(); + } + } + + protected void writeObject(HierarchicalStreamWriter writer, MarshallingContext context, String name, Object value) { + if (value != null) { + writer.startNode(name); + context.convertAnother(value); + writer.endNode(); + } + } + + protected void writeList(HierarchicalStreamWriter writer, String listName, String itemName, Iterable<String> list) { + if (list != null) { + java.util.Iterator<String> i = list.iterator(); + if (i.hasNext()) { + writer.startNode(listName); + while (i.hasNext()) { + writer.startNode(itemName); + writer.setValue(i.next()); + writer.endNode(); + } + writer.endNode(); + } + + } + } + + protected void writeObjectList(HierarchicalStreamWriter writer, MarshallingContext context, String listName, String itemName, Iterable<? extends Object> list) { + if (list != null) { + java.util.Iterator<? extends Object> i = list.iterator(); + if (i.hasNext()) { + writer.startNode(listName); + while (i.hasNext()) { + writeObject(writer, context, itemName, i.next()); + } + writer.endNode(); + } + + } + } + + protected void readNodes(HierarchicalStreamReader reader, NodeReader nodeReader) { + while (reader.hasMoreChildren()) { + reader.moveDown(); + nodeReader.onNode(reader, reader.getNodeName(), reader.getValue()); + reader.moveUp(); + } + } + + protected List<String> readList(HierarchicalStreamReader reader) { + List<String> list = new ArrayList<String>(); + while (reader.hasMoreChildren()) { + reader.moveDown(); + list.add(reader.getValue()); + reader.moveUp(); + } + return list; + } + + protected <T> List<T> readObjectList(HierarchicalStreamReader reader, UnmarshallingContext context, Class<? extends T> clazz) { + List<T> list = new ArrayList<T>(); + while (reader.hasMoreChildren()) { + reader.moveDown(); + list.add((T) context.convertAnother(reader.getValue(), clazz)); + reader.moveUp(); + } + return list; + } + + public interface NodeReader { + void onNode(HierarchicalStreamReader reader, String name, String value); + } +} diff --git a/drools-maven-plugin-example/src/main/resources/META-INF/kproject.xml b/drools-maven-plugin-example/src/main/resources/META-INF/kproject.xml index a5f271f9573..f8d80417680 100644 --- a/drools-maven-plugin-example/src/main/resources/META-INF/kproject.xml +++ b/drools-maven-plugin-example/src/main/resources/META-INF/kproject.xml @@ -1,56 +1,24 @@ -<org.drools.kproject.KProjectImpl> - <kBases> - <entry> - <string>org.drools.FireAlarmKBase</string> - <org.drools.kproject.KBaseImpl> - <namespace>org.drools</namespace> - <name>FireAlarmKBase</name> - <includes/> - <files> - <string>org.drools.sample/alarm.drl</string> - <string>org.drools.sample/rules.drl</string> - <string>org.drools.sample/rules2.drl</string> - </files> - <kSessions> - <entry> - <string>org.drools.FireAlarmKBase.session</string> - <org.drools.kproject.KSessionImpl> - <namespace>org.drools</namespace> - <name>FireAlarmKBase.session</name> - <type>stateful</type> - <annotations/> - <kBase reference="../../../.."/> - </org.drools.kproject.KSessionImpl> - </entry> - </kSessions> - <kProject reference="../../../.."/> - </org.drools.kproject.KBaseImpl> - </entry> - <entry> - <string>org.test.KBase1</string> - <org.drools.kproject.KBaseImpl> - <namespace>org.test</namespace> - <name>KBase1</name> - <includes/> - <files> - <string>org.drools.test/rule.drl</string> - <string>org.drools.test/decA.drl</string> - <string>org.drools.test/decB.drl</string> - </files> - <kSessions> - <entry> - <string>org.test.KBase1.session</string> - <org.drools.kproject.KSessionImpl> - <namespace>org.test</namespace> - <name>KBase1.session</name> - <type>stateful</type> - <annotations/> - <kBase reference="../../../.."/> - </org.drools.kproject.KSessionImpl> - </entry> - </kSessions> - <kProject reference="../../../.."/> - </org.drools.kproject.KBaseImpl> - </entry> - </kBases> -</org.drools.kproject.KProjectImpl> \ No newline at end of file +<kproject> + <kbases> + <kbase name="FireAlarmKBase" namespace="org.drools"> + <files> + <file>org.drools.sample/alarm.drl</file> + <file>org.drools.sample/rules.drl</file> + <file>org.drools.sample/rules2.drl</file> + </files> + <ksessions> + <ksession name="FireAlarmKBase.session" namespace="org.drools" type="stateful"/> + </ksessions> + </kbase> + <kbase name="KBase1" namespace="org.test"> + <files> + <file>org.drools.test/rule.drl</file> + <file>org.drools.test/decA.drl</file> + <file>org.drools.test/decB.drl</file> + </files> + <ksessions> + <ksession name="KBase1.session" namespace="org.test" type="stateful"/> + </ksessions> + </kbase> + </kbases> +</kproject> \ No newline at end of file
f1ac1054e3fc59f52237fb83da52c53dffe71de3
intellij-community
use common ExceptionUtil--
p
https://github.com/JetBrains/intellij-community
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IteratorNextDoesNotThrowNoSuchElementExceptionInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IteratorNextDoesNotThrowNoSuchElementExceptionInspection.java index 174bfa908c9bf..8119b1510d404 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IteratorNextDoesNotThrowNoSuchElementExceptionInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/bugs/IteratorNextDoesNotThrowNoSuchElementExceptionInspection.java @@ -15,17 +15,17 @@ */ package com.siyeh.ig.bugs; +import com.intellij.codeInsight.ExceptionUtil; import com.intellij.psi.*; import com.siyeh.HardcodedMethodConstants; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; -import com.siyeh.ig.psiutils.ExceptionUtils; import com.siyeh.ig.psiutils.IteratorUtils; import com.siyeh.ig.psiutils.MethodUtils; import org.jetbrains.annotations.NotNull; -import java.util.Set; +import java.util.List; public class IteratorNextDoesNotThrowNoSuchElementExceptionInspection extends BaseInspection { @@ -65,9 +65,7 @@ public void visitMethod(@NotNull PsiMethod method) { HardcodedMethodConstants.NEXT)) { return; } - final Set<PsiClassType> exceptions = - ExceptionUtils.calculateExceptionsThrown(method); - for (final PsiType exception : exceptions) { + for (final PsiType exception : ExceptionUtil.getThrownExceptions(method)) { if (exception.equalsToText( "java.util.NoSuchElementException")) { return; @@ -103,8 +101,7 @@ public void visitMethodCallExpression( if (method == null) { return; } - final Set<PsiClassType> exceptions = - ExceptionUtils.calculateExceptionsThrown(method); + final List<PsiClassType> exceptions = ExceptionUtil.getThrownExceptions(method); for (final PsiType exception : exceptions) { if (exception.equalsToText( "java.util.NoSuchElementException")) { diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspection.java index 98ec40b4dd996..86d83dc25e35a 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/ExpectedExceptionNeverThrownInspection.java @@ -16,6 +16,7 @@ package com.siyeh.ig.junit; import com.intellij.codeInsight.AnnotationUtil; +import com.intellij.codeInsight.ExceptionUtil; import com.intellij.psi.*; import com.intellij.psi.util.InheritanceUtil; import com.siyeh.InspectionGadgetsBundle; @@ -25,6 +26,7 @@ import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import java.util.List; import java.util.Set; public class ExpectedExceptionNeverThrownInspection extends BaseInspection { @@ -84,7 +86,7 @@ public void visitMethod(PsiMethod method) { InheritanceUtil.isInheritor(aClass, CommonClassNames.JAVA_LANG_ERROR)) { return; } - final Set<PsiClassType> exceptionsThrown = ExceptionUtils.calculateExceptionsThrown(body); + final List<PsiClassType> exceptionsThrown = ExceptionUtil.getThrownExceptions(body); if (exceptionsThrown.contains(classType)) { return; }
6945d04785d7322df45b5c71053ba18431f606cd
orientdb
Further work or traverse: - supported new- OSQLPredicate to specify a predicate using SQL language--
a
https://github.com/orientechnologies/orientdb
diff --git a/build.number b/build.number index 19e55caca3e..1c3c6d61de5 100644 --- a/build.number +++ b/build.number @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sat Apr 28 19:00:06 CEST 2012 -build.number=11815 +#Sat Apr 28 20:56:54 CEST 2012 +build.number=11818 diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/traverse/OTraverse.java b/core/src/main/java/com/orientechnologies/orient/core/command/traverse/OTraverse.java index 2416ee1d4c8..358eedfa27b 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/command/traverse/OTraverse.java +++ b/core/src/main/java/com/orientechnologies/orient/core/command/traverse/OTraverse.java @@ -45,7 +45,7 @@ public class OTraverse implements OCommand, Iterable<OIdentifiable>, Iterator<OI * * @see com.orientechnologies.orient.core.command.OCommand#execute() */ - public Object execute() { + public List<OIdentifiable> execute() { final List<OIdentifiable> result = new ArrayList<OIdentifiable>(); while (hasNext()) result.add(next()); @@ -114,6 +114,17 @@ public OTraverseContext getContext() { return context; } + public OTraverse target(final Iterable<? extends OIdentifiable> iTarget) { + return target(iTarget.iterator()); + } + + public OTraverse target(final OIdentifiable... iRecords) { + final List<OIdentifiable> list = new ArrayList<OIdentifiable>(); + for (OIdentifiable id : iRecords) + list.add(id); + return target(list.iterator()); + } + @SuppressWarnings("unchecked") public OTraverse target(final Iterator<? extends OIdentifiable> iTarget) { target = iTarget; @@ -147,6 +158,12 @@ public OTraverse fields(final Collection<String> iFields) { return this; } + public OTraverse fields(final String... iFields) { + for (String f : iFields) + field(f); + return this; + } + public List<String> getFields() { return fields; } diff --git a/core/src/main/java/com/orientechnologies/orient/core/command/traverse/OTraverseContext.java b/core/src/main/java/com/orientechnologies/orient/core/command/traverse/OTraverseContext.java index 297e8846907..47f06163454 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/command/traverse/OTraverseContext.java +++ b/core/src/main/java/com/orientechnologies/orient/core/command/traverse/OTraverseContext.java @@ -28,9 +28,9 @@ public class OTraverseContext implements OCommandContext { private OCommandContext nestedStack; - private Set<ORID> allTraversed = new HashSet<ORID>(); - private List<OTraverseAbstractProcess<?>> stack = new ArrayList<OTraverseAbstractProcess<?>>(); - private int depth = -1; + private Set<ORID> history = new HashSet<ORID>(); + private List<OTraverseAbstractProcess<?>> stack = new ArrayList<OTraverseAbstractProcess<?>>(); + private int depth = -1; public void push(final OTraverseAbstractProcess<?> iProcess) { stack.add(iProcess); @@ -55,11 +55,11 @@ public void reset() { } public boolean isAlreadyTraversed(final OIdentifiable identity) { - return allTraversed.contains(identity.getIdentity()); + return history.contains(identity.getIdentity()); } public void addTraversed(final OIdentifiable identity) { - allTraversed.add(identity.getIdentity()); + history.add(identity.getIdentity()); } public int incrementDepth() { @@ -77,6 +77,8 @@ else if ("path".equalsIgnoreCase(iName)) return getPath(); else if ("stack".equalsIgnoreCase(iName)) return stack; + else if ("history".equalsIgnoreCase(iName)) + return history; else if (nestedStack != null) // DELEGATE nestedStack.getVariable(iName); diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/OSQLHelper.java b/core/src/main/java/com/orientechnologies/orient/core/sql/OSQLHelper.java index 11f34176254..e1668449d26 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/OSQLHelper.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/OSQLHelper.java @@ -39,6 +39,7 @@ import com.orientechnologies.orient.core.sql.filter.OSQLFilterItemField; import com.orientechnologies.orient.core.sql.filter.OSQLFilterItemParameter; import com.orientechnologies.orient.core.sql.filter.OSQLFilterItemVariable; +import com.orientechnologies.orient.core.sql.filter.OSQLPredicate; import com.orientechnologies.orient.core.sql.functions.OSQLFunctionRuntime; /** @@ -182,7 +183,7 @@ else if (t == OType.DATE || t == OType.DATETIME) return null; } - public static Object parseValue(final OSQLFilter iSQLFilter, final OCommandToParse iCommand, final String iWord, + public static Object parseValue(final OSQLPredicate iSQLFilter, final OCommandToParse iCommand, final String iWord, final OCommandContext iContext) { if (iWord.charAt(0) == OStringSerializerHelper.PARAMETER_POSITIONAL || iWord.charAt(0) == OStringSerializerHelper.PARAMETER_NAMED) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilter.java b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilter.java index 4c15ece5ec2..7a23f87dcc7 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilter.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilter.java @@ -17,27 +17,20 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import java.util.Locale; import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; import com.orientechnologies.common.parser.OStringParser; import com.orientechnologies.orient.core.command.OCommandContext; import com.orientechnologies.orient.core.command.OCommandExecutor; import com.orientechnologies.orient.core.command.OCommandManager; import com.orientechnologies.orient.core.command.OCommandPredicate; -import com.orientechnologies.orient.core.command.OCommandToParse; import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal; -import com.orientechnologies.orient.core.db.record.ODatabaseRecord; import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.exception.OCommandExecutionException; import com.orientechnologies.orient.core.exception.OQueryParsingException; import com.orientechnologies.orient.core.id.ORecordId; import com.orientechnologies.orient.core.metadata.schema.OClass; -import com.orientechnologies.orient.core.metadata.schema.OProperty; import com.orientechnologies.orient.core.record.ORecord; import com.orientechnologies.orient.core.record.ORecordSchemaAware; import com.orientechnologies.orient.core.serialization.serializer.OStringSerializerHelper; @@ -46,11 +39,7 @@ import com.orientechnologies.orient.core.sql.OCommandSQL; import com.orientechnologies.orient.core.sql.OCommandSQLParsingException; import com.orientechnologies.orient.core.sql.OCommandSQLResultset; -import com.orientechnologies.orient.core.sql.OSQLEngine; import com.orientechnologies.orient.core.sql.OSQLHelper; -import com.orientechnologies.orient.core.sql.operator.OQueryOperator; -import com.orientechnologies.orient.core.sql.operator.OQueryOperatorNot; -import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; /** * Parsed query. It's built once a query is parsed. @@ -58,26 +47,19 @@ * @author Luca Garulli * */ -public class OSQLFilter extends OCommandToParse implements OCommandPredicate { - protected ODatabaseRecord database; +public class OSQLFilter extends OSQLPredicate implements OCommandPredicate { protected Iterable<? extends OIdentifiable> targetRecords; protected Map<String, String> targetClusters; protected Map<OClass, String> targetClasses; protected String targetIndex; - protected Set<OProperty> properties = new HashSet<OProperty>(); - protected OSQLFilterCondition rootCondition; - protected List<String> recordTransformed; - protected List<OSQLFilterItemParameter> parameterItems; - protected int braces; - private OCommandContext context; public OSQLFilter(final String iText, final OCommandContext iContext) { + super(); context = iContext; - try { - database = ODatabaseRecordThreadLocal.INSTANCE.get(); - text = iText; - textUpperCase = text.toUpperCase(Locale.ENGLISH); + text = iText; + textUpperCase = iText.toUpperCase(); + try { if (extractTargets()) { // IF WHERE EXISTS EXTRACT CONDITIONS @@ -85,8 +67,17 @@ public OSQLFilter(final String iText, final OCommandContext iContext) { int newPos = OSQLHelper.nextWord(text, textUpperCase, currentPos, word, true); if (newPos > -1) { if (word.toString().equals(OCommandExecutorSQLAbstract.KEYWORD_WHERE)) { - currentPos = newPos; - rootCondition = (OSQLFilterCondition) extractConditions(null); + final int lastPos = newPos; + final String lastText = text; + final String lastTextUpperCase = textUpperCase; + + text(text.substring(newPos)); + + if (currentPos > -1) + currentPos += lastPos; + text = lastText; + textUpperCase = lastTextUpperCase; + } else if (word.toString().equals(OCommandExecutorSQLAbstract.KEYWORD_LIMIT) || word.toString().equals(OCommandExecutorSQLSelect.KEYWORD_ORDER) || word.toString().equals(OCommandExecutorSQLSelect.KEYWORD_SKIP)) @@ -115,7 +106,7 @@ public boolean evaluate(final ORecord<?> iRecord, final OCommandContext iContext @SuppressWarnings("unchecked") private boolean extractTargets() { - jumpWhiteSpaces(); + currentPos = OStringParser.jumpWhiteSpaces(text, currentPos); if (currentPos == -1) throw new OQueryParsingException("No query target found", text, 0); @@ -210,7 +201,7 @@ private boolean extractTargets() { if (targetClasses == null) targetClasses = new HashMap<OClass, String>(); - OClass cls = database.getMetadata().getSchema().getClass(subjectName); + final OClass cls = ODatabaseRecordThreadLocal.INSTANCE.get().getMetadata().getSchema().getClass(subjectName); if (cls == null) throw new OCommandExecutionException("Class '" + subjectName + "' was not found in current database"); @@ -222,213 +213,6 @@ private boolean extractTargets() { return currentPos > -1; } - private Object extractConditions(final OSQLFilterCondition iParentCondition) { - final int oldPosition = currentPos; - final String[] words = nextValue(true); - - if (words != null && words.length > 0 && (words[0].equalsIgnoreCase("SELECT") || words[0].equalsIgnoreCase("TRAVERSE"))) { - // SUB QUERY - final StringBuilder embedded = new StringBuilder(); - OStringSerializerHelper.getEmbedded(text, oldPosition - 1, -1, embedded); - currentPos += embedded.length() + 1; - return new OSQLSynchQuery<Object>(embedded.toString()); - } - - currentPos = oldPosition; - final OSQLFilterCondition currentCondition = extractCondition(); - - // CHECK IF THERE IS ANOTHER CONDITION ON RIGHT - if (!jumpWhiteSpaces()) - // END OF TEXT - return currentCondition; - - if (currentPos > -1 && text.charAt(currentPos) == ')') - return currentCondition; - - final OQueryOperator nextOperator = extractConditionOperator(); - if (nextOperator == null) - return currentCondition; - - if (nextOperator.precedence > currentCondition.getOperator().precedence) { - // SWAP ITEMS - final OSQLFilterCondition subCondition = new OSQLFilterCondition(currentCondition.right, nextOperator); - currentCondition.right = subCondition; - subCondition.right = extractConditions(subCondition); - return currentCondition; - } else { - final OSQLFilterCondition parentCondition = new OSQLFilterCondition(currentCondition, nextOperator); - parentCondition.right = extractConditions(parentCondition); - return parentCondition; - } - } - - protected OSQLFilterCondition extractCondition() { - if (!jumpWhiteSpaces()) - // END OF TEXT - return null; - - // EXTRACT ITEMS - Object left = extractConditionItem(true, 1); - - if (checkForEnd(left.toString())) - return null; - - final OQueryOperator oper; - final Object right; - - if (left instanceof OQueryOperator && ((OQueryOperator) left).isUnary()) { - oper = (OQueryOperator) left; - left = extractConditionItem(false, 1); - right = null; - } else { - oper = extractConditionOperator(); - right = oper != null ? extractConditionItem(false, oper.expectedRightWords) : null; - } - - // CREATE THE CONDITION OBJECT - return new OSQLFilterCondition(left, oper, right); - } - - protected boolean checkForEnd(final String iWord) { - if (iWord != null - && (iWord.equals(OCommandExecutorSQLSelect.KEYWORD_ORDER) || iWord.equals(OCommandExecutorSQLSelect.KEYWORD_LIMIT) || iWord - .equals(OCommandExecutorSQLSelect.KEYWORD_SKIP))) { - currentPos -= iWord.length(); - return true; - } - return false; - } - - private OQueryOperator extractConditionOperator() { - if (!jumpWhiteSpaces()) - // END OF PARSING: JUST RETURN - return null; - - if (text.charAt(currentPos) == ')') - // FOUND ')': JUST RETURN - return null; - - String word; - word = nextWord(true, " 0123456789'\""); - - if (checkForEnd(word)) - return null; - - for (OQueryOperator op : OSQLEngine.getInstance().getRecordOperators()) { - if (word.startsWith(op.keyword)) { - final List<String> params = new ArrayList<String>(); - // CHECK FOR PARAMETERS - if (word.length() > op.keyword.length() && word.charAt(op.keyword.length()) == OStringSerializerHelper.EMBEDDED_BEGIN) { - int paramBeginPos = currentPos - (word.length() - op.keyword.length()); - currentPos = OStringSerializerHelper.getParameters(text, paramBeginPos, -1, params); - } else if (!word.equals(op.keyword)) - throw new OQueryParsingException("Malformed usage of operator '" + op.toString() + "'. Parsed operator is: " + word); - - try { - return op.configure(params); - } catch (Exception e) { - throw new OQueryParsingException("Syntax error using the operator '" + op.toString() + "'. Syntax is: " + op.getSyntax()); - } - } - } - - throw new OQueryParsingException("Unknown operator " + word, text, currentPos); - } - - private Object extractConditionItem(final boolean iAllowOperator, final int iExpectedWords) { - final Object[] result = new Object[iExpectedWords]; - - for (int i = 0; i < iExpectedWords; ++i) { - final String[] words = nextValue(true); - if (words == null) - break; - - if (words[0].length() > 0 && words[0].charAt(0) == OStringSerializerHelper.EMBEDDED_BEGIN) { - braces++; - - // SUB-CONDITION - currentPos = currentPos - words[0].length() + 1; - - final Object subCondition = extractConditions(null); - - if (!jumpWhiteSpaces() || text.charAt(currentPos) == ')') - braces--; - - if (currentPos > -1) - currentPos++; - - result[i] = subCondition; - } else if (words[0].charAt(0) == OStringSerializerHelper.COLLECTION_BEGIN) { - // COLLECTION OF ELEMENTS - currentPos = currentPos - words[0].length(); - - final List<String> stringItems = new ArrayList<String>(); - currentPos = OStringSerializerHelper.getCollection(text, currentPos, stringItems); - - if (stringItems.get(0).charAt(0) == OStringSerializerHelper.COLLECTION_BEGIN) { - - final List<List<Object>> coll = new ArrayList<List<Object>>(); - for (String stringItem : stringItems) { - final List<String> stringSubItems = new ArrayList<String>(); - OStringSerializerHelper.getCollection(stringItem, 0, stringSubItems); - - coll.add(convertCollectionItems(stringSubItems)); - } - - result[i] = coll; - - } else { - result[i] = convertCollectionItems(stringItems); - } - - currentPos++; - - } else if (words[0].startsWith(OSQLFilterItemFieldAll.NAME + OStringSerializerHelper.EMBEDDED_BEGIN)) { - - result[i] = new OSQLFilterItemFieldAll(this, words[1]); - - } else if (words[0].startsWith(OSQLFilterItemFieldAny.NAME + OStringSerializerHelper.EMBEDDED_BEGIN)) { - - result[i] = new OSQLFilterItemFieldAny(this, words[1]); - - } else { - - if (words[0].equals("NOT")) { - if (iAllowOperator) - return new OQueryOperatorNot(); - else { - // GET THE NEXT VALUE - final String[] nextWord = nextValue(true); - if (nextWord != null && nextWord.length == 2) { - words[1] = words[1] + " " + nextWord[1]; - - if (words[1].endsWith(")")) - words[1] = words[1].substring(0, words[1].length() - 1); - } - } - } - - if (words[1].endsWith(")")) { - final int openParenthesis = words[1].indexOf('('); - if (openParenthesis == -1) - words[1] = words[1].substring(0, words[1].length() - 1); - } - - result[i] = OSQLHelper.parseValue(this, this, words[1], context); - } - } - - return iExpectedWords == 1 ? result[0] : result; - } - - private List<Object> convertCollectionItems(List<String> stringItems) { - List<Object> coll = new ArrayList<Object>(); - for (String s : stringItems) { - coll.add(OSQLHelper.parseValue(this, this, s, context)); - } - return coll; - } - public Map<String, String> getTargetClusters() { return targetClusters; } @@ -449,85 +233,6 @@ public OSQLFilterCondition getRootCondition() { return rootCondition; } - private String[] nextValue(final boolean iAdvanceWhenNotFound) { - if (!jumpWhiteSpaces()) - return null; - - int begin = currentPos; - char c; - char stringBeginCharacter = ' '; - int openBraces = 0; - int openBraket = 0; - boolean escaped = false; - boolean escapingOn = false; - - for (; currentPos < text.length(); ++currentPos) { - c = text.charAt(currentPos); - - if (stringBeginCharacter == ' ' && (c == '"' || c == '\'')) { - // QUOTED STRING: GET UNTIL THE END OF QUOTING - stringBeginCharacter = c; - } else if (stringBeginCharacter != ' ') { - // INSIDE TEXT - if (c == '\\') { - escapingOn = true; - escaped = true; - } else { - if (c == stringBeginCharacter && !escapingOn) { - stringBeginCharacter = ' '; - - if (openBraket == 0 && openBraces == 0) { - if (iAdvanceWhenNotFound) - currentPos++; - break; - } - } - - if (escapingOn) - escapingOn = false; - } - } else if (c == '#' && currentPos == begin) { - // BEGIN OF RID - } else if (c == '(') { - openBraces++; - } else if (c == ')' && openBraces > 0) { - openBraces--; - } else if (c == OStringSerializerHelper.COLLECTION_BEGIN) { - openBraket++; - } else if (c == OStringSerializerHelper.COLLECTION_END) { - openBraket--; - if (openBraket == 0 && openBraces == 0) { - // currentPos++; - // break; - } - } else if (c == ' ' && openBraces == 0) { - break; - } else if (!Character.isLetter(c) && !Character.isDigit(c) && c != '.' && c != '$' && c != ':' && c != '-' && c != '_' - && c != '+' && c != '@' && openBraces == 0 && openBraket == 0) { - if (iAdvanceWhenNotFound) - currentPos++; - break; - } - } - - if (escaped) - return new String[] { OStringSerializerHelper.decode(textUpperCase.substring(begin, currentPos)), - OStringSerializerHelper.decode(text.substring(begin, currentPos)) }; - else - return new String[] { textUpperCase.substring(begin, currentPos), text.substring(begin, currentPos) }; - } - - private String nextWord(final boolean iForceUpperCase, final String iSeparators) { - StringBuilder word = new StringBuilder(); - currentPos = OSQLHelper.nextWord(text, textUpperCase, currentPos, word, iForceUpperCase, iSeparators); - return word.toString(); - } - - private boolean jumpWhiteSpaces() { - currentPos = OStringParser.jumpWhiteSpaces(text, currentPos); - return currentPos > -1; - } - @Override public String toString() { if (rootCondition != null) @@ -535,52 +240,4 @@ public String toString() { return "Unparsed: " + text; } - /** - * Binds parameters. - * - * @param iArgs - */ - public void bindParameters(final Map<Object, Object> iArgs) { - if (parameterItems == null || iArgs == null || iArgs.size() == 0) - return; - - for (Entry<Object, Object> entry : iArgs.entrySet()) { - if (entry.getKey() instanceof Integer) - parameterItems.get(((Integer) entry.getKey())).setValue(entry.setValue(entry.getValue())); - else { - String paramName = entry.getKey().toString(); - for (OSQLFilterItemParameter value : parameterItems) { - if (value.getName().equalsIgnoreCase(paramName)) { - value.setValue(entry.getValue()); - break; - } - } - } - } - } - - public OSQLFilterItemParameter addParameter(final String iName) { - final String name; - if (iName.charAt(0) == OStringSerializerHelper.PARAMETER_NAMED) { - name = iName.substring(1); - - // CHECK THE PARAMETER NAME IS CORRECT - if (!OStringSerializerHelper.isAlphanumeric(name)) { - throw new OQueryParsingException("Parameter name '" + name + "' is invalid, only alphanumeric characters are allowed"); - } - } else - name = iName; - - final OSQLFilterItemParameter param = new OSQLFilterItemParameter(name); - - if (parameterItems == null) - parameterItems = new ArrayList<OSQLFilterItemParameter>(); - - parameterItems.add(param); - return param; - } - - public void setRootCondition(final OSQLFilterCondition iCondition) { - rootCondition = iCondition; - } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterCondition.java b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterCondition.java index 46262c81b26..2c8d701397e 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterCondition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterCondition.java @@ -47,271 +47,271 @@ * */ public class OSQLFilterCondition { - private static final String NULL_VALUE = "null"; - protected Object left; - protected OQueryOperator operator; - protected Object right; - - public OSQLFilterCondition(final Object iLeft, final OQueryOperator iOperator) { - this.left = iLeft; - this.operator = iOperator; - } - - public OSQLFilterCondition(final Object iLeft, final OQueryOperator iOperator, final Object iRight) { - this.left = iLeft; - this.operator = iOperator; - this.right = iRight; - } - - public Object evaluate(final OIdentifiable o, final OCommandContext iContext) { - // EXECUTE SUB QUERIES ONCE - if (left instanceof OSQLQuery<?>) - left = ((OSQLQuery<?>) left).setContext(iContext).execute(); - - if (right instanceof OSQLQuery<?>) - right = ((OSQLQuery<?>) right).setContext(iContext).execute(); - - Object l = evaluate(o, left, iContext); - Object r = evaluate(o, right, iContext); - - final Object[] convertedValues = checkForConversion(o, l, r); - if (convertedValues != null) { - l = convertedValues[0]; - r = convertedValues[1]; - } - - if (operator == null) { - if (l == null) - // THE LEFT RETURNED NULL - return Boolean.FALSE; - - // UNITARY OPERATOR: JUST RETURN LEFT RESULT - return l; - } - - return operator.evaluateRecord(o, this, l, r, iContext); - } - - public ORID getBeginRidRange() { - if (operator == null) - if (left instanceof OSQLFilterCondition) - return ((OSQLFilterCondition) left).getBeginRidRange(); - else - return null; - - return operator.getBeginRidRange(left, right); - } - - public ORID getEndRidRange() { - if (operator == null) - if (left instanceof OSQLFilterCondition) - return ((OSQLFilterCondition) left).getEndRidRange(); - else - return null; - - return operator.getEndRidRange(left, right); - } - - private Object[] checkForConversion(final OIdentifiable o, final Object l, final Object r) { - Object[] result = null; - - // DEFINED OPERATOR - if ((r instanceof String && r.equals(OSQLHelper.DEFINED)) || (l instanceof String && l.equals(OSQLHelper.DEFINED))) { - result = new Object[] { ((OSQLFilterItemAbstract) this.left).getRoot(), r }; - } - - // NOT_NULL OPERATOR - else if ((r instanceof String && r.equals(OSQLHelper.NOT_NULL)) || (l instanceof String && l.equals(OSQLHelper.NOT_NULL))) { - result = null; - } - - else if (l != null && r != null && !l.getClass().isAssignableFrom(r.getClass()) && !r.getClass().isAssignableFrom(l.getClass())) - // INTEGERS - if (r instanceof Integer && !(l instanceof Number)) { - if (l instanceof String && ((String) l).indexOf('.') > -1) - result = new Object[] { new Float((String) l).intValue(), r }; - else if (l instanceof Date) - result = new Object[] { ((Date) l).getTime(), r }; - else if (!(l instanceof OQueryRuntimeValueMulti) && !(l instanceof Collection<?>) && !l.getClass().isArray() - && !(l instanceof Map)) - result = new Object[] { getInteger(l), r }; - } else if (l instanceof Integer && !(r instanceof Number)) { - if (r instanceof String && ((String) r).indexOf('.') > -1) - result = new Object[] { l, new Float((String) r).intValue() }; - else if (r instanceof Date) - result = new Object[] { l, ((Date) r).getTime() }; - else if (!(r instanceof OQueryRuntimeValueMulti) && !(r instanceof Collection<?>) && !r.getClass().isArray() - && !(r instanceof Map)) - result = new Object[] { l, getInteger(r) }; - } - - // FLOATS - else if (r instanceof Float && !(l instanceof Float)) - result = new Object[] { getFloat(l), r }; - else if (l instanceof Float && !(r instanceof Float)) - result = new Object[] { l, getFloat(r) }; - - // DATES - else if (r instanceof Date && !(l instanceof Collection || l instanceof Date)) { - result = new Object[] { getDate(l), r }; - } else if (l instanceof Date && !(r instanceof Collection || r instanceof Date)) { - result = new Object[] { l, getDate(r) }; - } - - // RIDS - else if (r instanceof ORID && l instanceof String && !l.equals(OSQLHelper.NOT_NULL)) { - result = new Object[] { new ORecordId((String) l), r }; - } else if (l instanceof ORID && r instanceof String && !r.equals(OSQLHelper.NOT_NULL)) { - result = new Object[] { l, new ORecordId((String) r) }; - } - - return result; - } - - protected Integer getInteger(Object iValue) { - if (iValue == null) - return null; - - final String stringValue = iValue.toString(); - - if (NULL_VALUE.equals(stringValue)) - return null; - if (OSQLHelper.DEFINED.equals(stringValue)) - return null; - - if (OStringSerializerHelper.contains(stringValue, '.') || OStringSerializerHelper.contains(stringValue, ',')) - return (int) Float.parseFloat(stringValue); - else - return stringValue.length() > 0 ? new Integer(stringValue) : new Integer(0); - } - - protected Float getFloat(final Object iValue) { - if (iValue == null) - return null; - - final String stringValue = iValue.toString(); - - if (NULL_VALUE.equals(stringValue)) - return null; - - return stringValue.length() > 0 ? new Float(stringValue) : new Float(0); - } - - protected Date getDate(final Object iValue) { - if (iValue == null) - return null; - - if (iValue instanceof Long) - return new Date(((Long) iValue).longValue()); - - String stringValue = iValue.toString(); - - if (NULL_VALUE.equals(stringValue)) - return null; - - if (stringValue.length() <= 0) - return null; - - if (Pattern.matches("^\\d+$", stringValue)) { - return new Date(Long.valueOf(stringValue).longValue()); - } - - final OStorageConfiguration config = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration(); - - SimpleDateFormat formatter = config.getDateFormatInstance(); - - if (stringValue.length() > config.dateFormat.length()) { - // ASSUMES YOU'RE USING THE DATE-TIME FORMATTE - formatter = config.getDateTimeFormatInstance(); - } - - try { - return formatter.parse(stringValue); - } catch (ParseException pe) { - throw new OQueryParsingException("Error on conversion of date '" + stringValue + "' using the format: " - + formatter.toPattern()); - } - } - - protected Object evaluate(OIdentifiable o, final Object iValue, final OCommandContext iContext) { - if (o.getRecord().getInternalStatus() == ORecordElement.STATUS.NOT_LOADED) { - try { - o = o.getRecord().load(); - } catch (ORecordNotFoundException e) { - return null; - } - } - - if (iValue instanceof OSQLFilterItem) - return ((OSQLFilterItem) iValue).getValue(o, iContext); - - if (iValue instanceof OSQLFilterCondition) - // NESTED CONDITION: EVALUATE IT RECURSIVELY - return ((OSQLFilterCondition) iValue).evaluate(o, iContext); - - if (iValue instanceof OSQLFunctionRuntime) { - // STATELESS FUNCTION: EXECUTE IT - final OSQLFunctionRuntime f = (OSQLFunctionRuntime) iValue; - return f.execute(o, null); - } - - final Iterable<?> multiValue = OMultiValue.getMultiValueIterable(iValue); - - if (multiValue != null) { - // MULTI VALUE: RETURN A COPY - final ArrayList<Object> result = new ArrayList<Object>(OMultiValue.getSize(iValue)); - - for (final Object value : multiValue) { - if (value instanceof OSQLFilterItem) - result.add(((OSQLFilterItem) value).getValue(o, null)); - else - result.add(value); - } - return result; - } - - // SIMPLE VALUE: JUST RETURN IT - return iValue; - } - - @Override - public String toString() { - StringBuilder buffer = new StringBuilder(); - - buffer.append('('); - buffer.append(left); - if (operator != null) { - buffer.append(' '); - buffer.append(operator); - buffer.append(' '); - if (right instanceof String) - buffer.append('\''); - buffer.append(right); - if (right instanceof String) - buffer.append('\''); - buffer.append(')'); - } - - return buffer.toString(); - } - - public Object getLeft() { - return left; - } - - public Object getRight() { - return right; - } - - public OQueryOperator getOperator() { - return operator; - } - - public void setLeft(final Object iValue) { - left = iValue; - } - - public void setRight(final Object iValue) { - right = iValue; - } + private static final String NULL_VALUE = "null"; + protected Object left; + protected OQueryOperator operator; + protected Object right; + + public OSQLFilterCondition(final Object iLeft, final OQueryOperator iOperator) { + this.left = iLeft; + this.operator = iOperator; + } + + public OSQLFilterCondition(final Object iLeft, final OQueryOperator iOperator, final Object iRight) { + this.left = iLeft; + this.operator = iOperator; + this.right = iRight; + } + + public Object evaluate(final OIdentifiable o, final OCommandContext iContext) { + // EXECUTE SUB QUERIES ONCE + if (left instanceof OSQLQuery<?>) + left = ((OSQLQuery<?>) left).setContext(iContext).execute(); + + if (right instanceof OSQLQuery<?>) + right = ((OSQLQuery<?>) right).setContext(iContext).execute(); + + Object l = evaluate(o, left, iContext); + Object r = evaluate(o, right, iContext); + + final Object[] convertedValues = checkForConversion(o, l, r); + if (convertedValues != null) { + l = convertedValues[0]; + r = convertedValues[1]; + } + + if (operator == null) { + if (l == null) + // THE LEFT RETURNED NULL + return Boolean.FALSE; + + // UNITARY OPERATOR: JUST RETURN LEFT RESULT + return l; + } + + return operator.evaluateRecord(o, this, l, r, iContext); + } + + public ORID getBeginRidRange() { + if (operator == null) + if (left instanceof OSQLFilterCondition) + return ((OSQLFilterCondition) left).getBeginRidRange(); + else + return null; + + return operator.getBeginRidRange(left, right); + } + + public ORID getEndRidRange() { + if (operator == null) + if (left instanceof OSQLFilterCondition) + return ((OSQLFilterCondition) left).getEndRidRange(); + else + return null; + + return operator.getEndRidRange(left, right); + } + + private Object[] checkForConversion(final OIdentifiable o, final Object l, final Object r) { + Object[] result = null; + + // DEFINED OPERATOR + if ((r instanceof String && r.equals(OSQLHelper.DEFINED)) || (l instanceof String && l.equals(OSQLHelper.DEFINED))) { + result = new Object[] { ((OSQLFilterItemAbstract) this.left).getRoot(), r }; + } + + // NOT_NULL OPERATOR + else if ((r instanceof String && r.equals(OSQLHelper.NOT_NULL)) || (l instanceof String && l.equals(OSQLHelper.NOT_NULL))) { + result = null; + } + + else if (l != null && r != null && !l.getClass().isAssignableFrom(r.getClass()) && !r.getClass().isAssignableFrom(l.getClass())) + // INTEGERS + if (r instanceof Integer && !(l instanceof Number)) { + if (l instanceof String && ((String) l).indexOf('.') > -1) + result = new Object[] { new Float((String) l).intValue(), r }; + else if (l instanceof Date) + result = new Object[] { ((Date) l).getTime(), r }; + else if (!(l instanceof OQueryRuntimeValueMulti) && !(l instanceof Collection<?>) && !l.getClass().isArray() + && !(l instanceof Map)) + result = new Object[] { getInteger(l), r }; + } else if (l instanceof Integer && !(r instanceof Number)) { + if (r instanceof String && ((String) r).indexOf('.') > -1) + result = new Object[] { l, new Float((String) r).intValue() }; + else if (r instanceof Date) + result = new Object[] { l, ((Date) r).getTime() }; + else if (!(r instanceof OQueryRuntimeValueMulti) && !(r instanceof Collection<?>) && !r.getClass().isArray() + && !(r instanceof Map)) + result = new Object[] { l, getInteger(r) }; + } + + // FLOATS + else if (r instanceof Float && !(l instanceof Float)) + result = new Object[] { getFloat(l), r }; + else if (l instanceof Float && !(r instanceof Float)) + result = new Object[] { l, getFloat(r) }; + + // DATES + else if (r instanceof Date && !(l instanceof Collection || l instanceof Date)) { + result = new Object[] { getDate(l), r }; + } else if (l instanceof Date && !(r instanceof Collection || r instanceof Date)) { + result = new Object[] { l, getDate(r) }; + } + + // RIDS + else if (r instanceof ORID && l instanceof String && !l.equals(OSQLHelper.NOT_NULL)) { + result = new Object[] { new ORecordId((String) l), r }; + } else if (l instanceof ORID && r instanceof String && !r.equals(OSQLHelper.NOT_NULL)) { + result = new Object[] { l, new ORecordId((String) r) }; + } + + return result; + } + + protected Integer getInteger(Object iValue) { + if (iValue == null) + return null; + + final String stringValue = iValue.toString(); + + if (NULL_VALUE.equals(stringValue)) + return null; + if (OSQLHelper.DEFINED.equals(stringValue)) + return null; + + if (OStringSerializerHelper.contains(stringValue, '.') || OStringSerializerHelper.contains(stringValue, ',')) + return (int) Float.parseFloat(stringValue); + else + return stringValue.length() > 0 ? new Integer(stringValue) : new Integer(0); + } + + protected Float getFloat(final Object iValue) { + if (iValue == null) + return null; + + final String stringValue = iValue.toString(); + + if (NULL_VALUE.equals(stringValue)) + return null; + + return stringValue.length() > 0 ? new Float(stringValue) : new Float(0); + } + + protected Date getDate(final Object iValue) { + if (iValue == null) + return null; + + if (iValue instanceof Long) + return new Date(((Long) iValue).longValue()); + + String stringValue = iValue.toString(); + + if (NULL_VALUE.equals(stringValue)) + return null; + + if (stringValue.length() <= 0) + return null; + + if (Pattern.matches("^\\d+$", stringValue)) { + return new Date(Long.valueOf(stringValue).longValue()); + } + + final OStorageConfiguration config = ODatabaseRecordThreadLocal.INSTANCE.get().getStorage().getConfiguration(); + + SimpleDateFormat formatter = config.getDateFormatInstance(); + + if (stringValue.length() > config.dateFormat.length()) { + // ASSUMES YOU'RE USING THE DATE-TIME FORMATTE + formatter = config.getDateTimeFormatInstance(); + } + + try { + return formatter.parse(stringValue); + } catch (ParseException pe) { + throw new OQueryParsingException("Error on conversion of date '" + stringValue + "' using the format: " + + formatter.toPattern()); + } + } + + protected Object evaluate(OIdentifiable o, final Object iValue, final OCommandContext iContext) { + if (o.getRecord().getInternalStatus() == ORecordElement.STATUS.NOT_LOADED) { + try { + o = o.getRecord().load(); + } catch (ORecordNotFoundException e) { + return null; + } + } + + if (iValue instanceof OSQLFilterItem) + return ((OSQLFilterItem) iValue).getValue(o, iContext); + + if (iValue instanceof OSQLFilterCondition) + // NESTED CONDITION: EVALUATE IT RECURSIVELY + return ((OSQLFilterCondition) iValue).evaluate(o, iContext); + + if (iValue instanceof OSQLFunctionRuntime) { + // STATELESS FUNCTION: EXECUTE IT + final OSQLFunctionRuntime f = (OSQLFunctionRuntime) iValue; + return f.execute(o, null); + } + + final Iterable<?> multiValue = OMultiValue.getMultiValueIterable(iValue); + + if (multiValue != null) { + // MULTI VALUE: RETURN A COPY + final ArrayList<Object> result = new ArrayList<Object>(OMultiValue.getSize(iValue)); + + for (final Object value : multiValue) { + if (value instanceof OSQLFilterItem) + result.add(((OSQLFilterItem) value).getValue(o, null)); + else + result.add(value); + } + return result; + } + + // SIMPLE VALUE: JUST RETURN IT + return iValue; + } + + @Override + public String toString() { + StringBuilder buffer = new StringBuilder(); + + buffer.append('('); + buffer.append(left); + if (operator != null) { + buffer.append(' '); + buffer.append(operator); + buffer.append(' '); + if (right instanceof String) + buffer.append('\''); + buffer.append(right); + if (right instanceof String) + buffer.append('\''); + buffer.append(')'); + } + + return buffer.toString(); + } + + public Object getLeft() { + return left; + } + + public Object getRight() { + return right; + } + + public OQueryOperator getOperator() { + return operator; + } + + public void setLeft(final Object iValue) { + left = iValue; + } + + public void setRight(final Object iValue) { + right = iValue; + } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldAll.java b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldAll.java index 31de0848b1a..67bff01bb6d 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldAll.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldAll.java @@ -28,7 +28,7 @@ public class OSQLFilterItemFieldAll extends OSQLFilterItemFieldMultiAbstract { public static final String NAME = "ALL"; public static final String FULL_NAME = "ALL()"; - public OSQLFilterItemFieldAll(final OSQLFilter iQueryCompiled, final String iName) { + public OSQLFilterItemFieldAll(final OSQLPredicate iQueryCompiled, final String iName) { super(iQueryCompiled, iName, OStringSerializerHelper.getParameters(iName)); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldAny.java b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldAny.java index fad3f6aac1c..145347f9e86 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldAny.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldAny.java @@ -25,19 +25,19 @@ * */ public class OSQLFilterItemFieldAny extends OSQLFilterItemFieldMultiAbstract { - public static final String NAME = "ANY"; - public static final String FULL_NAME = "ANY()"; + public static final String NAME = "ANY"; + public static final String FULL_NAME = "ANY()"; - public OSQLFilterItemFieldAny(final OSQLFilter iQueryCompiled, final String iName) { - super(iQueryCompiled, iName, OStringSerializerHelper.getParameters(iName)); - } + public OSQLFilterItemFieldAny(final OSQLPredicate iQueryCompiled, final String iName) { + super(iQueryCompiled, iName, OStringSerializerHelper.getParameters(iName)); + } - @Override - public String getRoot() { - return FULL_NAME; - } + @Override + public String getRoot() { + return FULL_NAME; + } - @Override - protected void setRoot(final OCommandToParse iQueryToParse, final String iRoot) { - } + @Override + protected void setRoot(final OCommandToParse iQueryToParse, final String iRoot) { + } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldMultiAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldMultiAbstract.java index 6181f1a7180..9002a582da5 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldMultiAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLFilterItemFieldMultiAbstract.java @@ -30,25 +30,25 @@ * */ public abstract class OSQLFilterItemFieldMultiAbstract extends OSQLFilterItemAbstract { - private List<String> names; + private List<String> names; - public OSQLFilterItemFieldMultiAbstract(final OSQLFilter iQueryCompiled, final String iName, final List<String> iNames) { - super(iQueryCompiled, iName); - names = iNames; - } + public OSQLFilterItemFieldMultiAbstract(final OSQLPredicate iQueryCompiled, final String iName, final List<String> iNames) { + super(iQueryCompiled, iName); + names = iNames; + } - public Object getValue(final OIdentifiable iRecord, OCommandContext iContetx) { - if (names.size() == 1) - return transformValue(iRecord, ODocumentHelper.getIdentifiableValue(iRecord, names.get(0))); + public Object getValue(final OIdentifiable iRecord, OCommandContext iContetx) { + if (names.size() == 1) + return transformValue(iRecord, ODocumentHelper.getIdentifiableValue(iRecord, names.get(0))); - final Object[] values = ((ODocument) iRecord).fieldValues(); + final Object[] values = ((ODocument) iRecord).fieldValues(); - if (hasChainOperators()) { - // TRANSFORM ALL THE VALUES - for (int i = 0; i < values.length; ++i) - values[i] = transformValue(iRecord, values[i]); - } + if (hasChainOperators()) { + // TRANSFORM ALL THE VALUES + for (int i = 0; i < values.length; ++i) + values[i] = transformValue(iRecord, values[i]); + } - return new OQueryRuntimeValueMulti(this, values); - } + return new OQueryRuntimeValueMulti(this, values); + } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLPredicate.java b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLPredicate.java new file mode 100644 index 00000000000..54eca8c0392 --- /dev/null +++ b/core/src/main/java/com/orientechnologies/orient/core/sql/filter/OSQLPredicate.java @@ -0,0 +1,435 @@ +/* + * Copyright 1999-2010 Luca Garulli (l.garulli--at--orientechnologies.com) + * + * 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.orientechnologies.orient.core.sql.filter; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.orientechnologies.common.parser.OStringParser; +import com.orientechnologies.orient.core.command.OCommandContext; +import com.orientechnologies.orient.core.command.OCommandPredicate; +import com.orientechnologies.orient.core.command.OCommandToParse; +import com.orientechnologies.orient.core.exception.OQueryParsingException; +import com.orientechnologies.orient.core.metadata.schema.OProperty; +import com.orientechnologies.orient.core.record.ORecord; +import com.orientechnologies.orient.core.record.ORecordSchemaAware; +import com.orientechnologies.orient.core.serialization.serializer.OStringSerializerHelper; +import com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect; +import com.orientechnologies.orient.core.sql.OSQLEngine; +import com.orientechnologies.orient.core.sql.OSQLHelper; +import com.orientechnologies.orient.core.sql.operator.OQueryOperator; +import com.orientechnologies.orient.core.sql.operator.OQueryOperatorNot; +import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; + +/** + * Parses text in SQL format and build a tree of conditions. + * + * @author Luca Garulli + * + */ +public class OSQLPredicate extends OCommandToParse implements OCommandPredicate { + protected Set<OProperty> properties = new HashSet<OProperty>(); + protected OSQLFilterCondition rootCondition; + protected List<String> recordTransformed; + protected List<OSQLFilterItemParameter> parameterItems; + protected int braces; + protected OCommandContext context; + + public OSQLPredicate() { + } + + public OSQLPredicate(final String iText) { + text(iText); + } + + public OSQLPredicate text(final String iText) { + try { + text = iText; + textUpperCase = text.toUpperCase(Locale.ENGLISH); + currentPos = 0; + jumpWhiteSpaces(); + + rootCondition = (OSQLFilterCondition) extractConditions(null); + } catch (OQueryParsingException e) { + if (e.getText() == null) + // QUERY EXCEPTION BUT WITHOUT TEXT: NEST IT + throw new OQueryParsingException("Error on parsing query", text, currentPos, e); + + throw e; + } catch (Throwable t) { + throw new OQueryParsingException("Error on parsing query", text, currentPos, t); + } + return this; + } + + public boolean evaluate(final ORecord<?> iRecord, final OCommandContext iContext) { + if (rootCondition == null) + return true; + + return (Boolean) rootCondition.evaluate((ORecordSchemaAware<?>) iRecord, iContext); + } + + private Object extractConditions(final OSQLFilterCondition iParentCondition) { + final int oldPosition = currentPos; + final String[] words = nextValue(true); + + if (words != null && words.length > 0 && (words[0].equalsIgnoreCase("SELECT") || words[0].equalsIgnoreCase("TRAVERSE"))) { + // SUB QUERY + final StringBuilder embedded = new StringBuilder(); + OStringSerializerHelper.getEmbedded(text, oldPosition - 1, -1, embedded); + currentPos += embedded.length() + 1; + return new OSQLSynchQuery<Object>(embedded.toString()); + } + + currentPos = oldPosition; + final OSQLFilterCondition currentCondition = extractCondition(); + + // CHECK IF THERE IS ANOTHER CONDITION ON RIGHT + if (!jumpWhiteSpaces()) + // END OF TEXT + return currentCondition; + + if (currentPos > -1 && text.charAt(currentPos) == ')') + return currentCondition; + + final OQueryOperator nextOperator = extractConditionOperator(); + if (nextOperator == null) + return currentCondition; + + if (nextOperator.precedence > currentCondition.getOperator().precedence) { + // SWAP ITEMS + final OSQLFilterCondition subCondition = new OSQLFilterCondition(currentCondition.right, nextOperator); + currentCondition.right = subCondition; + subCondition.right = extractConditions(subCondition); + return currentCondition; + } else { + final OSQLFilterCondition parentCondition = new OSQLFilterCondition(currentCondition, nextOperator); + parentCondition.right = extractConditions(parentCondition); + return parentCondition; + } + } + + protected OSQLFilterCondition extractCondition() { + if (!jumpWhiteSpaces()) + // END OF TEXT + return null; + + // EXTRACT ITEMS + Object left = extractConditionItem(true, 1); + + if (checkForEnd(left.toString())) + return null; + + final OQueryOperator oper; + final Object right; + + if (left instanceof OQueryOperator && ((OQueryOperator) left).isUnary()) { + oper = (OQueryOperator) left; + left = extractConditionItem(false, 1); + right = null; + } else { + oper = extractConditionOperator(); + right = oper != null ? extractConditionItem(false, oper.expectedRightWords) : null; + } + + // CREATE THE CONDITION OBJECT + return new OSQLFilterCondition(left, oper, right); + } + + protected boolean checkForEnd(final String iWord) { + if (iWord != null + && (iWord.equals(OCommandExecutorSQLSelect.KEYWORD_ORDER) || iWord.equals(OCommandExecutorSQLSelect.KEYWORD_LIMIT) || iWord + .equals(OCommandExecutorSQLSelect.KEYWORD_SKIP))) { + currentPos -= iWord.length(); + return true; + } + return false; + } + + private OQueryOperator extractConditionOperator() { + if (!jumpWhiteSpaces()) + // END OF PARSING: JUST RETURN + return null; + + if (text.charAt(currentPos) == ')') + // FOUND ')': JUST RETURN + return null; + + String word; + word = nextWord(true, " 0123456789'\""); + + if (checkForEnd(word)) + return null; + + for (OQueryOperator op : OSQLEngine.getInstance().getRecordOperators()) { + if (word.startsWith(op.keyword)) { + final List<String> params = new ArrayList<String>(); + // CHECK FOR PARAMETERS + if (word.length() > op.keyword.length() && word.charAt(op.keyword.length()) == OStringSerializerHelper.EMBEDDED_BEGIN) { + int paramBeginPos = currentPos - (word.length() - op.keyword.length()); + currentPos = OStringSerializerHelper.getParameters(text, paramBeginPos, -1, params); + } else if (!word.equals(op.keyword)) + throw new OQueryParsingException("Malformed usage of operator '" + op.toString() + "'. Parsed operator is: " + word); + + try { + return op.configure(params); + } catch (Exception e) { + throw new OQueryParsingException("Syntax error using the operator '" + op.toString() + "'. Syntax is: " + op.getSyntax()); + } + } + } + + throw new OQueryParsingException("Unknown operator " + word, text, currentPos); + } + + private Object extractConditionItem(final boolean iAllowOperator, final int iExpectedWords) { + final Object[] result = new Object[iExpectedWords]; + + for (int i = 0; i < iExpectedWords; ++i) { + final String[] words = nextValue(true); + if (words == null) + break; + + if (words[0].length() > 0 && words[0].charAt(0) == OStringSerializerHelper.EMBEDDED_BEGIN) { + braces++; + + // SUB-CONDITION + currentPos = currentPos - words[0].length() + 1; + + final Object subCondition = extractConditions(null); + + if (!jumpWhiteSpaces() || text.charAt(currentPos) == ')') + braces--; + + if (currentPos > -1) + currentPos++; + + result[i] = subCondition; + } else if (words[0].charAt(0) == OStringSerializerHelper.COLLECTION_BEGIN) { + // COLLECTION OF ELEMENTS + currentPos = currentPos - words[0].length(); + + final List<String> stringItems = new ArrayList<String>(); + currentPos = OStringSerializerHelper.getCollection(text, currentPos, stringItems); + + if (stringItems.get(0).charAt(0) == OStringSerializerHelper.COLLECTION_BEGIN) { + + final List<List<Object>> coll = new ArrayList<List<Object>>(); + for (String stringItem : stringItems) { + final List<String> stringSubItems = new ArrayList<String>(); + OStringSerializerHelper.getCollection(stringItem, 0, stringSubItems); + + coll.add(convertCollectionItems(stringSubItems)); + } + + result[i] = coll; + + } else { + result[i] = convertCollectionItems(stringItems); + } + + currentPos++; + + } else if (words[0].startsWith(OSQLFilterItemFieldAll.NAME + OStringSerializerHelper.EMBEDDED_BEGIN)) { + + result[i] = new OSQLFilterItemFieldAll(this, words[1]); + + } else if (words[0].startsWith(OSQLFilterItemFieldAny.NAME + OStringSerializerHelper.EMBEDDED_BEGIN)) { + + result[i] = new OSQLFilterItemFieldAny(this, words[1]); + + } else { + + if (words[0].equals("NOT")) { + if (iAllowOperator) + return new OQueryOperatorNot(); + else { + // GET THE NEXT VALUE + final String[] nextWord = nextValue(true); + if (nextWord != null && nextWord.length == 2) { + words[1] = words[1] + " " + nextWord[1]; + + if (words[1].endsWith(")")) + words[1] = words[1].substring(0, words[1].length() - 1); + } + } + } + + if (words[1].endsWith(")")) { + final int openParenthesis = words[1].indexOf('('); + if (openParenthesis == -1) + words[1] = words[1].substring(0, words[1].length() - 1); + } + + result[i] = OSQLHelper.parseValue(this, this, words[1], context); + } + } + + return iExpectedWords == 1 ? result[0] : result; + } + + private List<Object> convertCollectionItems(List<String> stringItems) { + List<Object> coll = new ArrayList<Object>(); + for (String s : stringItems) { + coll.add(OSQLHelper.parseValue(this, this, s, context)); + } + return coll; + } + + public OSQLFilterCondition getRootCondition() { + return rootCondition; + } + + private String[] nextValue(final boolean iAdvanceWhenNotFound) { + if (!jumpWhiteSpaces()) + return null; + + int begin = currentPos; + char c; + char stringBeginCharacter = ' '; + int openBraces = 0; + int openBraket = 0; + boolean escaped = false; + boolean escapingOn = false; + + for (; currentPos < text.length(); ++currentPos) { + c = text.charAt(currentPos); + + if (stringBeginCharacter == ' ' && (c == '"' || c == '\'')) { + // QUOTED STRING: GET UNTIL THE END OF QUOTING + stringBeginCharacter = c; + } else if (stringBeginCharacter != ' ') { + // INSIDE TEXT + if (c == '\\') { + escapingOn = true; + escaped = true; + } else { + if (c == stringBeginCharacter && !escapingOn) { + stringBeginCharacter = ' '; + + if (openBraket == 0 && openBraces == 0) { + if (iAdvanceWhenNotFound) + currentPos++; + break; + } + } + + if (escapingOn) + escapingOn = false; + } + } else if (c == '#' && currentPos == begin) { + // BEGIN OF RID + } else if (c == '(') { + openBraces++; + } else if (c == ')' && openBraces > 0) { + openBraces--; + } else if (c == OStringSerializerHelper.COLLECTION_BEGIN) { + openBraket++; + } else if (c == OStringSerializerHelper.COLLECTION_END) { + openBraket--; + if (openBraket == 0 && openBraces == 0) { + // currentPos++; + // break; + } + } else if (c == ' ' && openBraces == 0) { + break; + } else if (!Character.isLetter(c) && !Character.isDigit(c) && c != '.' && c != '$' && c != ':' && c != '-' && c != '_' + && c != '+' && c != '@' && openBraces == 0 && openBraket == 0) { + if (iAdvanceWhenNotFound) + currentPos++; + break; + } + } + + if (escaped) + return new String[] { OStringSerializerHelper.decode(textUpperCase.substring(begin, currentPos)), + OStringSerializerHelper.decode(text.substring(begin, currentPos)) }; + else + return new String[] { textUpperCase.substring(begin, currentPos), text.substring(begin, currentPos) }; + } + + private String nextWord(final boolean iForceUpperCase, final String iSeparators) { + StringBuilder word = new StringBuilder(); + currentPos = OSQLHelper.nextWord(text, textUpperCase, currentPos, word, iForceUpperCase, iSeparators); + return word.toString(); + } + + private boolean jumpWhiteSpaces() { + currentPos = OStringParser.jumpWhiteSpaces(text, currentPos); + return currentPos > -1; + } + + @Override + public String toString() { + if (rootCondition != null) + return "Parsed: " + rootCondition.toString(); + return "Unparsed: " + text; + } + + /** + * Binds parameters. + * + * @param iArgs + */ + public void bindParameters(final Map<Object, Object> iArgs) { + if (parameterItems == null || iArgs == null || iArgs.size() == 0) + return; + + for (Entry<Object, Object> entry : iArgs.entrySet()) { + if (entry.getKey() instanceof Integer) + parameterItems.get(((Integer) entry.getKey())).setValue(entry.setValue(entry.getValue())); + else { + String paramName = entry.getKey().toString(); + for (OSQLFilterItemParameter value : parameterItems) { + if (value.getName().equalsIgnoreCase(paramName)) { + value.setValue(entry.getValue()); + break; + } + } + } + } + } + + public OSQLFilterItemParameter addParameter(final String iName) { + final String name; + if (iName.charAt(0) == OStringSerializerHelper.PARAMETER_NAMED) { + name = iName.substring(1); + + // CHECK THE PARAMETER NAME IS CORRECT + if (!OStringSerializerHelper.isAlphanumeric(name)) { + throw new OQueryParsingException("Parameter name '" + name + "' is invalid, only alphanumeric characters are allowed"); + } + } else + name = iName; + + final OSQLFilterItemParameter param = new OSQLFilterItemParameter(name); + + if (parameterItems == null) + parameterItems = new ArrayList<OSQLFilterItemParameter>(); + + parameterItems.add(param); + return param; + } + + public void setRootCondition(final OSQLFilterCondition iCondition) { + rootCondition = iCondition; + } +} diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TraverseTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TraverseTest.java index f26315aace1..bdd1bd0f66d 100644 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TraverseTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/TraverseTest.java @@ -24,9 +24,14 @@ import org.testng.annotations.Parameters; import org.testng.annotations.Test; +import com.orientechnologies.orient.core.command.OCommandContext; +import com.orientechnologies.orient.core.command.OCommandPredicate; +import com.orientechnologies.orient.core.command.traverse.OTraverse; import com.orientechnologies.orient.core.db.graph.OGraphDatabase; import com.orientechnologies.orient.core.db.record.OIdentifiable; +import com.orientechnologies.orient.core.record.ORecord; import com.orientechnologies.orient.core.record.impl.ODocument; +import com.orientechnologies.orient.core.sql.filter.OSQLPredicate; import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; @Test @@ -89,18 +94,27 @@ public void deinit() { database.close(); } - public void traverseAllFromActorNoWhere() { + public void traverseSQLAllFromActorNoWhere() { List<ODocument> result1 = database.command(new OSQLSynchQuery<ODocument>("traverse * from " + tomCruise.getIdentity())) .execute(); Assert.assertEquals(result1.size(), totalElements); } - public void traverseOutFromOneActorNoWhere() { + public void traverseAPIAllFromActorNoWhere() { + List<OIdentifiable> result1 = new OTraverse().fields("*").target(tomCruise.getIdentity()).execute(); + Assert.assertEquals(result1.size(), totalElements); + } + + public void traverseSQLOutFromOneActorNoWhere() { database.command(new OSQLSynchQuery<ODocument>("traverse out from " + tomCruise.getIdentity())).execute(); } + public void traverseAPIOutFromOneActorNoWhere() { + new OTraverse().field("out").target(tomCruise.getIdentity()).execute(); + } + @Test - public void traverseOutFromActor1Depth() { + public void traverseSQLOutFromActor1Depth() { List<ODocument> result1 = database.command( new OSQLSynchQuery<ODocument>("traverse out from " + tomCruise.getIdentity() + " where $depth <= 1")).execute(); @@ -111,14 +125,14 @@ public void traverseOutFromActor1Depth() { } @Test - public void traverseDept02() { + public void traverseSQLDept02() { List<ODocument> result1 = database.command(new OSQLSynchQuery<ODocument>("traverse any() from Movie where $depth < 2")) .execute(); } @Test - public void traverseMoviesOnly() { + public void traverseSQLMoviesOnly() { List<ODocument> result1 = database.command( new OSQLSynchQuery<ODocument>("select from ( traverse any() from Movie ) where @class = 'Movie'")).execute(); Assert.assertTrue(result1.size() > 0); @@ -128,7 +142,7 @@ public void traverseMoviesOnly() { } @Test - public void traversePerClassFields() { + public void traverseSQLPerClassFields() { List<ODocument> result1 = database.command( new OSQLSynchQuery<ODocument>("select from ( traverse V.out, E.in from " + tomCruise.getIdentity() + ") where @class = 'Movie'")).execute(); @@ -139,7 +153,7 @@ public void traversePerClassFields() { } @Test - public void traverseMoviesOnlyDepth() { + public void traverseSQLMoviesOnlyDepth() { List<ODocument> result1 = database.command( new OSQLSynchQuery<ODocument>("select from ( traverse * from " + tomCruise.getIdentity() + " where $depth <= 1 ) where @class = 'Movie'")).execute(); @@ -170,7 +184,7 @@ public void traverseSelect() { } @Test - public void traverseSelectAndTraverseNested() { + public void traverseSQLSelectAndTraverseNested() { List<ODocument> result1 = database.command( new OSQLSynchQuery<ODocument>("traverse * from ( select from ( traverse * from " + tomCruise.getIdentity() + " where $depth <= 2 ) where @class = 'Movie' )")).execute(); @@ -178,7 +192,15 @@ public void traverseSelectAndTraverseNested() { } @Test - public void traverseIterating() { + public void traverseAPISelectAndTraverseNested() { + List<ODocument> result1 = database.command( + new OSQLSynchQuery<ODocument>("traverse * from ( select from ( traverse * from " + tomCruise.getIdentity() + + " where $depth <= 2 ) where @class = 'Movie' )")).execute(); + Assert.assertEquals(result1.size(), totalElements); + } + + @Test + public void traverseSQLIterating() { int cycles = 0; for (OIdentifiable id : new OSQLSynchQuery<ODocument>("traverse * from Movie where $depth < 2")) { cycles++; @@ -186,6 +208,29 @@ public void traverseIterating() { Assert.assertTrue(cycles > 0); } + @Test + public void traverseAPIIterating() { + int cycles = 0; + for (OIdentifiable id : new OTraverse().target(database.browseClass("Movie").iterator()).predicate(new OCommandPredicate() { + public boolean evaluate(ORecord<?> iRecord, OCommandContext iContext) { + return ((Integer) iContext.getVariable("depth")) <= 2; + } + })) { + cycles++; + } + Assert.assertTrue(cycles > 0); + } + + @Test + public void traverseAPIandSQLIterating() { + int cycles = 0; + for (OIdentifiable id : new OTraverse().target(database.browseClass("Movie").iterator()).predicate( + new OSQLPredicate("$depth <= 2"))) { + cycles++; + } + Assert.assertTrue(cycles > 0); + } + @Test public void traverseSelectIterable() { int cycles = 0;
3dbcd5fa303e8eecaaa2b5b256f96e0127be0cdf
orientdb
Improved import/export tools--
p
https://github.com/orientechnologies/orientdb
diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/document/OLazyRecordMap.java b/core/src/main/java/com/orientechnologies/orient/core/db/document/OLazyRecordMap.java index 1ad048c2794..2a36c82afdb 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/db/document/OLazyRecordMap.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/document/OLazyRecordMap.java @@ -15,7 +15,7 @@ */ package com.orientechnologies.orient.core.db.document; -import java.util.HashMap; +import java.util.LinkedHashMap; import com.orientechnologies.orient.core.db.record.ODatabaseRecord; import com.orientechnologies.orient.core.id.ORID; @@ -24,7 +24,7 @@ import com.orientechnologies.orient.core.record.ORecordInternal; @SuppressWarnings({ "serial" }) -public class OLazyRecordMap extends HashMap<String, Object> { +public class OLazyRecordMap extends LinkedHashMap<String, Object> { private ODatabaseRecord<?> database; private byte recordType; private boolean converted = false; diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java index 5dc9d28b596..24e14cd65f6 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java @@ -533,14 +533,15 @@ private ORID linkToStream(final StringBuilder buffer, final ORecordSchemaAware<? ((ODatabaseRecord<ORecordInternal<?>>) iLinkedRecord.getDatabase()).save((ORecordInternal<?>) iLinkedRecord); } - if (iLinkedRecord instanceof ORecordSchemaAware<?>) { - final ORecordSchemaAware<?> schemaAwareRecord = (ORecordSchemaAware<?>) iLinkedRecord; - - if (schemaAwareRecord.getClassName() != null) { - buffer.append(schemaAwareRecord.getClassName()); - buffer.append(OStringSerializerHelper.CLASS_SEPARATOR); - } - } + // TEMPORARY DISABLED SINCE IT MAKES NOT SENSE AT CURRENT RELEASE (0.9.21)! + // if (iLinkedRecord instanceof ORecordSchemaAware<?>) { + // final ORecordSchemaAware<?> schemaAwareRecord = (ORecordSchemaAware<?>) iLinkedRecord; + // + // if (schemaAwareRecord.getClassName() != null) { + // buffer.append(schemaAwareRecord.getClassName()); + // buffer.append(OStringSerializerHelper.CLASS_SEPARATOR); + // } + // } if (iParentRecord.getDatabase() instanceof ODatabaseRecord<?>) { final ODatabaseRecord<?> db = (ODatabaseRecord<?>) iParentRecord.getDatabase(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerJSON.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerJSON.java index 5160e702809..6d862c64651 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerJSON.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerJSON.java @@ -19,8 +19,8 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -158,11 +158,12 @@ private Object getValue(final ODocument iRecord, String iFieldName, String iFiel return fromString(iRecord.getDatabase(), iFieldValue, null); else { // MAP - final Map<String, Object> embeddedMap; - embeddedMap = new HashMap<String, Object>(); + final Map<String, Object> embeddedMap = new LinkedHashMap<String, Object>(); for (int i = 0; i < fields.length; i += 2) { iFieldName = fields[i]; + if (iFieldName.length() >= 2) + iFieldName = iFieldName.substring(1, iFieldName.length() - 1); iFieldValue = fields[i + 1]; iFieldValueAsString = iFieldValue.length() >= 2 ? iFieldValue.substring(1, iFieldValue.length() - 1) : iFieldValue; diff --git a/tools/src/main/java/com/orientechnologies/utility/cmd/OConsoleDatabaseCompare.java b/tools/src/main/java/com/orientechnologies/utility/cmd/OConsoleDatabaseCompare.java index 757ae944452..b19b9734d81 100644 --- a/tools/src/main/java/com/orientechnologies/utility/cmd/OConsoleDatabaseCompare.java +++ b/tools/src/main/java/com/orientechnologies/utility/cmd/OConsoleDatabaseCompare.java @@ -25,14 +25,13 @@ import com.orientechnologies.orient.core.storage.OStorage; import com.orientechnologies.utility.console.OCommandListener; -public class OConsoleDatabaseCompare { - private OStorage storage1; - private OStorage storage2; - private OCommandListener listener; - private int differences = 0; +public class OConsoleDatabaseCompare extends OConsoleDatabaseImpExpAbstract { + private OStorage storage1; + private OStorage storage2; + private int differences = 0; public OConsoleDatabaseCompare(final String iDb1URL, final String iDb2URL, final OCommandListener iListener) throws IOException { - listener = iListener; + super(null, null, iListener); listener.onMessage("\nComparing two databases:\n1) " + iDb1URL + "\n2) " + iDb2URL + "\n"); storage1 = Orient.instance().accessToLocalStorage(iDb1URL, "rw"); @@ -78,27 +77,36 @@ private boolean compareClusters() { int cluster2Id; boolean ok; - for (String cl1 : storage1.getClusterNames()) { + for (String clusterName : storage1.getClusterNames()) { + // CHECK IF THE CLUSTER IS INCLUDED + if (includeClusters != null) { + if (!includeClusters.contains(clusterName)) + continue; + } else if (excludeClusters != null) { + if (excludeClusters.contains(clusterName)) + continue; + } + ok = true; - cluster2Id = storage2.getClusterIdByName(cl1); + cluster2Id = storage2.getClusterIdByName(clusterName); - listener.onMessage("\n- Checking cluster " + String.format("%-25s: ", "'" + cl1 + "'")); + listener.onMessage("\n- Checking cluster " + String.format("%-25s: ", "'" + clusterName + "'")); if (cluster2Id == -1) { - listener.onMessage("KO: cluster name " + cl1 + " was not found on database " + storage2); + listener.onMessage("KO: cluster name " + clusterName + " was not found on database " + storage2); ++differences; ok = false; } - if (cluster2Id != storage1.getClusterIdByName(cl1)) { - listener.onMessage("KO: cluster id is different for cluster " + cl1 + ": " + storage1.getClusterIdByName(cl1) + " <-> " - + cluster2Id); + if (cluster2Id != storage1.getClusterIdByName(clusterName)) { + listener.onMessage("KO: cluster id is different for cluster " + clusterName + ": " + + storage1.getClusterIdByName(clusterName) + " <-> " + cluster2Id); ++differences; ok = false; } if (storage1.count(cluster2Id) != storage2.count(cluster2Id)) { - listener.onMessage("KO: record number are different in cluster '" + cl1 + "' (id=" + cluster2Id + "): " + listener.onMessage("KO: number of records differents in cluster '" + clusterName + "' (id=" + cluster2Id + "): " + storage1.count(cluster2Id) + " <-> " + storage2.count(cluster2Id)); ++differences; ok = false; @@ -116,51 +124,81 @@ private boolean compareRecords() { listener.onMessage("\nStarting deep comparison record by record. It can takes some minutes. Wait please..."); int clusterId; - long clusterMax; ORawBuffer buffer1, buffer2; for (String clusterName : storage1.getClusterNames()) { + // CHECK IF THE CLUSTER IS INCLUDED + if (includeClusters != null) { + if (!includeClusters.contains(clusterName)) + continue; + } else if (excludeClusters != null) { + if (excludeClusters.contains(clusterName)) + continue; + } + clusterId = storage1.getClusterIdByName(clusterName); - clusterMax = storage1.getClusterLastEntryPosition(clusterId); - for (int i = 0; i < clusterMax; ++i) { - buffer1 = storage1.readRecord(null, 0, clusterId, i, null); - buffer2 = storage2.readRecord(null, 0, clusterId, i, null); - if (buffer1 == null && buffer2 == null || buffer1.buffer == null && buffer2.buffer == null) - continue; + long db1Max = storage1.getClusterLastEntryPosition(clusterId); + long db2Max = storage2.getClusterLastEntryPosition(clusterId); - if (buffer1.recordType != buffer2.recordType) { - listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " recordType is different: " + (char) buffer1.recordType - + " <-> " + (char) buffer2.recordType); - ++differences; - } + long clusterMax = Math.max(db1Max, db2Max); + for (int i = 0; i < clusterMax; ++i) { + buffer1 = i < db1Max ? storage1.readRecord(null, 0, clusterId, i, null) : null; + buffer2 = i < db2Max ? storage2.readRecord(null, 0, clusterId, i, null) : null; - if (buffer1.buffer == null && buffer2.buffer != null) { - listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " content is different: null <-> " + buffer2.buffer.length); - ++differences; - } else if (buffer1.buffer != null && buffer2.buffer == null) { - listener - .onMessage("\n- KO: RID=" + clusterId + ":" + i + " content is different: " + buffer1.buffer.length + " <-> null"); + if (buffer1 == null && buffer2 == null) + // BOTH RECORD NULL, OK + continue; + else if (buffer1 == null && buffer2 != null) { + // REC1 NULL + listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " is null in DB1"); ++differences; - } else if (buffer1.buffer.length != buffer2.buffer.length) { - listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " content length is different: " + buffer1.buffer.length - + " <-> " + buffer2.buffer.length); - if (buffer1.recordType == ODocument.RECORD_TYPE || buffer1.recordType == ORecordFlat.RECORD_TYPE - || buffer1.recordType == ORecordColumn.RECORD_TYPE) - listener.onMessage("\n--- REC1: " + new String(buffer1.buffer)); - if (buffer2.recordType == ODocument.RECORD_TYPE || buffer2.recordType == ORecordFlat.RECORD_TYPE - || buffer2.recordType == ORecordColumn.RECORD_TYPE) - listener.onMessage("\n--- REC2: " + new String(buffer2.buffer)); - + } else if (buffer1 != null && buffer2 == null) { + // REC2 NULL + listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " is null in DB2"); ++differences; } else { - // CHECK BYTE PER BYTE - for (int b = 0; b < buffer1.buffer.length; ++b) { - if (buffer1.buffer[b] != buffer2.buffer[b]) { - listener.onMessage("\n--- KO: RID=" + clusterId + ":" + i + " content is different at byte #" + b + ": " - + buffer1.buffer[b] + " <-> " + buffer2.buffer[b]); - ++differences; + if (buffer1.recordType != buffer2.recordType) { + listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " recordType is different: " + (char) buffer1.recordType + + " <-> " + (char) buffer2.recordType); + ++differences; + } + + if (buffer1.buffer == null && buffer2.buffer != null) { + listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " content is different: null <-> " + buffer2.buffer.length); + ++differences; + + } else if (buffer1.buffer != null && buffer2.buffer == null) { + listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " content is different: " + buffer1.buffer.length + + " <-> null"); + ++differences; + + } else if (buffer1.buffer.length != buffer2.buffer.length) { + listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " content length is different: " + buffer1.buffer.length + + " <-> " + buffer2.buffer.length); + if (buffer1.recordType == ODocument.RECORD_TYPE || buffer1.recordType == ORecordFlat.RECORD_TYPE + || buffer1.recordType == ORecordColumn.RECORD_TYPE) + listener.onMessage("\n--- REC1: " + new String(buffer1.buffer)); + if (buffer2.recordType == ODocument.RECORD_TYPE || buffer2.recordType == ORecordFlat.RECORD_TYPE + || buffer2.recordType == ORecordColumn.RECORD_TYPE) + listener.onMessage("\n--- REC2: " + new String(buffer2.buffer)); + listener.onMessage("\n"); + + ++differences; + + } else { + // CHECK BYTE PER BYTE + for (int b = 0; b < buffer1.buffer.length; ++b) { + if (buffer1.buffer[b] != buffer2.buffer[b]) { + listener.onMessage("\n- KO: RID=" + clusterId + ":" + i + " content is different at byte #" + b + ": " + + buffer1.buffer[b] + " <-> " + buffer2.buffer[b]); + listener.onMessage("\n--- REC1: " + new String(buffer1.buffer)); + listener.onMessage("\n--- REC2: " + new String(buffer2.buffer)); + listener.onMessage("\n"); + ++differences; + break; + } } } }
642ed17a4808e36f1458546cc66d52e212cc5acf
hadoop
HADOOP-6951. Distinct minicluster services (e.g.- NN and JT) overwrite each other's service policies. Contributed by Aaron T.- Myers.--git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1002896 13f79535-47bb-0310-9956-ffa450edef68-
c
https://github.com/apache/hadoop
diff --git a/CHANGES.txt b/CHANGES.txt index 3850d6ecad5d9..0590fa7e4b981 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -250,6 +250,9 @@ Trunk (unreleased changes) HADOOP-6940. RawLocalFileSystem's markSupported method misnamed markSupport. (Tom White via eli). + HADOOP-6951. Distinct minicluster services (e.g. NN and JT) overwrite each + other's service policies. (Aaron T. Myers via tomwhite) + Release 0.21.0 - Unreleased INCOMPATIBLE CHANGES diff --git a/src/java/org/apache/hadoop/ipc/Server.java b/src/java/org/apache/hadoop/ipc/Server.java index e8ee049cb6025..01d76d886ae4f 100644 --- a/src/java/org/apache/hadoop/ipc/Server.java +++ b/src/java/org/apache/hadoop/ipc/Server.java @@ -60,6 +60,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.CommonConfigurationKeys; import org.apache.hadoop.io.BytesWritable; @@ -78,6 +79,7 @@ import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.authorize.ProxyUsers; import org.apache.hadoop.security.authorize.AuthorizationException; +import org.apache.hadoop.security.authorize.PolicyProvider; import org.apache.hadoop.security.authorize.ServiceAuthorizationManager; import org.apache.hadoop.security.token.TokenIdentifier; import org.apache.hadoop.security.token.SecretManager; @@ -182,6 +184,7 @@ public static String getRemoteAddress() { private Configuration conf; private SecretManager<TokenIdentifier> secretManager; + private ServiceAuthorizationManager serviceAuthorizationManager = new ServiceAuthorizationManager(); private int maxQueueSize; private final int maxRespSize; @@ -239,6 +242,22 @@ public RpcMetrics getRpcMetrics() { return rpcMetrics; } + /** + * Refresh the service authorization ACL for the service handled by this server. + */ + public void refreshServiceAcl(Configuration conf, PolicyProvider provider) { + serviceAuthorizationManager.refresh(conf, provider); + } + + /** + * Returns a handle to the serviceAuthorizationManager (required in tests) + * @return instance of ServiceAuthorizationManager for this server + */ + @InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"}) + public ServiceAuthorizationManager getServiceAuthorizationManager() { + return serviceAuthorizationManager; + } + /** A call queued for handling. */ private static class Call { private int id; // the client's call id @@ -1652,7 +1671,7 @@ public void authorize(UserGroupInformation user, throw new AuthorizationException("Unknown protocol: " + connection.getProtocol()); } - ServiceAuthorizationManager.authorize(user, protocol, getConf(), hostname); + serviceAuthorizationManager.authorize(user, protocol, getConf(), hostname); } } diff --git a/src/java/org/apache/hadoop/security/authorize/ServiceAuthorizationManager.java b/src/java/org/apache/hadoop/security/authorize/ServiceAuthorizationManager.java index 3f78cf9ef2e4f..a73fa2cd9fec5 100644 --- a/src/java/org/apache/hadoop/security/authorize/ServiceAuthorizationManager.java +++ b/src/java/org/apache/hadoop/security/authorize/ServiceAuthorizationManager.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.IdentityHashMap; import java.util.Map; +import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -43,7 +44,7 @@ public class ServiceAuthorizationManager { private static final Log LOG = LogFactory .getLog(ServiceAuthorizationManager.class); - private static Map<Class<?>, AccessControlList> protocolToAcl = + private Map<Class<?>, AccessControlList> protocolToAcl = new IdentityHashMap<Class<?>, AccessControlList>(); /** @@ -73,7 +74,7 @@ public class ServiceAuthorizationManager { * @param hostname fully qualified domain name of the client * @throws AuthorizationException on authorization failure */ - public static void authorize(UserGroupInformation user, + public void authorize(UserGroupInformation user, Class<?> protocol, Configuration conf, String hostname @@ -129,7 +130,7 @@ public static void authorize(UserGroupInformation user, AUDITLOG.info(AUTHZ_SUCCESSFULL_FOR + user + " for protocol="+protocol); } - public static synchronized void refresh(Configuration conf, + public synchronized void refresh(Configuration conf, PolicyProvider provider) { // Get the system property 'hadoop.policy.file' String policyFile = @@ -158,4 +159,9 @@ public static synchronized void refresh(Configuration conf, // Flip to the newly parsed permissions protocolToAcl = newAcls; } + + // Package-protected for use in tests. + Set<Class<?>> getProtocolsWithAcls() { + return protocolToAcl.keySet(); + } } diff --git a/src/test/core/org/apache/hadoop/ipc/TestRPC.java b/src/test/core/org/apache/hadoop/ipc/TestRPC.java index c87391e4d58b8..9ca6a6e936142 100644 --- a/src/test/core/org/apache/hadoop/ipc/TestRPC.java +++ b/src/test/core/org/apache/hadoop/ipc/TestRPC.java @@ -41,7 +41,6 @@ import org.apache.hadoop.security.authorize.AuthorizationException; import org.apache.hadoop.security.authorize.PolicyProvider; import org.apache.hadoop.security.authorize.Service; -import org.apache.hadoop.security.authorize.ServiceAuthorizationManager; import org.apache.hadoop.security.AccessControlException; import static org.mockito.Mockito.*; @@ -364,11 +363,11 @@ public Service[] getServices() { } private void doRPCs(Configuration conf, boolean expectFailure) throws Exception { - ServiceAuthorizationManager.refresh(conf, new TestPolicyProvider()); - Server server = RPC.getServer(TestProtocol.class, new TestImpl(), ADDRESS, 0, 5, true, conf, null); + server.refreshServiceAcl(conf, new TestPolicyProvider()); + TestProtocol proxy = null; server.start();
1803fb26dffce892ca6fbf258970e56bed06b0dd
Vala
Support array_length_type for fields Fixes part of bug 529866.
a
https://github.com/GNOME/vala/
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala index ec7dd838f6..72d169f322 100644 --- a/codegen/valaccodearraymodule.vala +++ b/codegen/valaccodearraymodule.vala @@ -311,6 +311,10 @@ internal class Vala.CCodeArrayModule : CCodeMethodCallModule { } else { length_expr = new CCodeMemberAccess (inst, length_cname); } + + if (field.array_length_type != null) { + length_expr = new CCodeCastExpression (length_expr, "gint"); + } } else { length_expr = new CCodeIdentifier (get_array_length_cname (field.get_cname (), dim)); } diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala index 98eee7c7de..bcfc8aa518 100644 --- a/vala/valacodewriter.vala +++ b/vala/valacodewriter.vala @@ -628,7 +628,8 @@ public class Vala.CodeWriter : CodeVisitor { bool custom_ctype = (f.get_ctype () != null); bool custom_cheaders = (f.parent_symbol is Namespace); bool custom_array_length_cname = (f.get_array_length_cname () != null); - if (custom_cname || custom_ctype || custom_cheaders || custom_array_length_cname || (f.no_array_length && f.field_type is ArrayType)) { + bool custom_array_length_type = (f.array_length_type != null); + if (custom_cname || custom_ctype || custom_cheaders || custom_array_length_cname || custom_array_length_type || (f.no_array_length && f.field_type is ArrayType)) { write_indent (); write_string ("[CCode ("); @@ -663,12 +664,22 @@ public class Vala.CodeWriter : CodeVisitor { if (f.array_null_terminated) { write_string (", array_null_terminated = true"); } - } else if (custom_array_length_cname) { - if (custom_cname || custom_ctype || custom_cheaders) { - write_string (", "); + } else { + if (custom_array_length_cname) { + if (custom_cname || custom_ctype || custom_cheaders) { + write_string (", "); + } + + write_string ("array_length_cname = \"%s\"".printf (f.get_array_length_cname ())); } - write_string ("array_length_cname = \"%s\"".printf (f.get_array_length_cname ())); + if (custom_array_length_type) { + if (custom_cname || custom_ctype || custom_cheaders || custom_array_length_cname) { + write_string (", "); + } + + write_string ("array_length_type = \"%s\"".printf (f.array_length_type)); + } } } diff --git a/vala/valafield.vala b/vala/valafield.vala index 209c024e0b..87d12c12c0 100644 --- a/vala/valafield.vala +++ b/vala/valafield.vala @@ -93,6 +93,11 @@ public class Vala.Field : Member, Lockable { get { return (array_length_cexpr != null); } } + /** + * Specifies a custom type for the array length. + */ + public string? array_length_type { get; set; default = null; } + private string? array_length_cname; private string? array_length_cexpr; @@ -229,6 +234,9 @@ public class Vala.Field : Member, Lockable { if (a.has_argument ("array_length_cexpr")) { set_array_length_cexpr (a.get_string ("array_length_cexpr")); } + if (a.has_argument ("array_length_type")) { + array_length_type = a.get_string ("array_length_type"); + } if (a.has_argument ("delegate_target")) { no_delegate_target = !a.get_bool ("delegate_target"); } diff --git a/vapigen/valagidlparser.vala b/vapigen/valagidlparser.vala index 47e1fea529..72f10179bd 100644 --- a/vapigen/valagidlparser.vala +++ b/vapigen/valagidlparser.vala @@ -1974,6 +1974,7 @@ public class Vala.GIdlParser : CodeVisitor { string cheader_filename = null; string ctype = null; string array_length_cname = null; + string array_length_type = null; bool array_null_terminated = false; var attributes = get_attributes ("%s.%s".printf (current_data_type.get_cname (), node.name)); @@ -2018,6 +2019,8 @@ public class Vala.GIdlParser : CodeVisitor { } } else if (nv[0] == "array_length_cname") { array_length_cname = eval (nv[1]); + } else if (nv[0] == "array_length_type") { + array_length_type = eval (nv[1]); } } } @@ -2055,8 +2058,13 @@ public class Vala.GIdlParser : CodeVisitor { field.array_null_terminated = true; } - if (array_length_cname != null) { - field.set_array_length_cname (array_length_cname); + if (array_length_cname != null || array_length_type != null) { + if (array_length_cname != null) { + field.set_array_length_cname (array_length_cname); + } + if (array_length_type != null) { + field.array_length_type = array_length_type; + } } else { field.no_array_length = true; }
bd92322d22be4a00f1a6fbd4fe45660a920eca6d
hadoop
HADOOP-6367. Removes Access Token implementation- from common. Contributed by Kan Zhang.--git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@881509 13f79535-47bb-0310-9956-ffa450edef68-
p
https://github.com/apache/hadoop
diff --git a/CHANGES.txt b/CHANGES.txt index 89901793723e3..2c19f62abc95d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -653,6 +653,9 @@ Release 0.21.0 - Unreleased HADOOP-6343. Log unexpected throwable object caught in RPC. (Jitendra Nath Pandey via szetszwo) + HADOOP-6367. Removes Access Token implementation from common. + (Kan Zhang via ddas) + OPTIMIZATIONS HADOOP-5595. NameNode does not need to run a replicator to choose a diff --git a/src/java/core-default.xml b/src/java/core-default.xml index dc77fd5c90417..9389ffb6e047b 100644 --- a/src/java/core-default.xml +++ b/src/java/core-default.xml @@ -269,29 +269,6 @@ <description>Disk usage statistics refresh interval in msec.</description> </property> -<property> - <name>fs.access.token.enable</name> - <value>false</value> - <description> - If "true", access tokens are used as capabilities for accessing datanodes. - If "false", no access tokens are checked on accessing datanodes. - </description> -</property> - -<property> - <name>fs.access.key.update.interval</name> - <value>600</value> - <description> - Interval in minutes at which namenode updates its access keys. - </description> -</property> - -<property> - <name>fs.access.token.lifetime</name> - <value>600</value> - <description>The lifetime of access tokens in minutes.</description> -</property> - <property> <name>fs.s3.block.size</name> <value>67108864</value> diff --git a/src/java/org/apache/hadoop/conf/Configuration.java b/src/java/org/apache/hadoop/conf/Configuration.java index e1b3be4f7b1ff..e12817b42f5b2 100644 --- a/src/java/org/apache/hadoop/conf/Configuration.java +++ b/src/java/org/apache/hadoop/conf/Configuration.java @@ -1757,12 +1757,6 @@ private static void addDeprecatedKeys() { new String[]{CommonConfigurationKeys.FS_CLIENT_BUFFER_DIR_KEY}); Configuration.addDeprecation("hadoop.native.lib", new String[]{CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY}); - Configuration.addDeprecation("dfs.access.token.enable", - new String[]{CommonConfigurationKeys.FS_ACCESS_TOKEN_ENABLE_KEY}); - Configuration.addDeprecation("dfs.access.key.update.interval", - new String[]{CommonConfigurationKeys.FS_ACCESS_KEY_UPDATE_INTERVAL_KEY}); - Configuration.addDeprecation("dfs.access.token.lifetime", - new String[]{CommonConfigurationKeys.FS_ACCESS_TOKEN_LIFETIME_KEY}); Configuration.addDeprecation("fs.default.name", new String[]{CommonConfigurationKeys.FS_DEFAULT_NAME_KEY}); } diff --git a/src/java/org/apache/hadoop/fs/CommonConfigurationKeys.java b/src/java/org/apache/hadoop/fs/CommonConfigurationKeys.java index d721f5ed04a0c..5dcc2cb5ab133 100644 --- a/src/java/org/apache/hadoop/fs/CommonConfigurationKeys.java +++ b/src/java/org/apache/hadoop/fs/CommonConfigurationKeys.java @@ -43,15 +43,6 @@ public class CommonConfigurationKeys { public static final int FS_PERMISSIONS_UMASK_DEFAULT = 0022; public static final String FS_DF_INTERVAL_KEY = "fs.df.interval"; public static final long FS_DF_INTERVAL_DEFAULT = 60000; - public static final String FS_ACCESS_TOKEN_ENABLE_KEY = - "fs.access.token.enable"; - public static final boolean FS_ACCESS_TOKEN_ENABLE_DEFAULT = false; - public static final String FS_ACCESS_KEY_UPDATE_INTERVAL_KEY = - "fs.access.key.update.interval"; - public static final long FS_ACCESS_KEY_UPDATE_INTERVAL_DEFAULT = 600; - public static final String FS_ACCESS_TOKEN_LIFETIME_KEY = - "fs.access.token.lifetime"; - public static final long FS_ACCESS_TOKEN_LIFETIME_DEFAULT = 600; //Defaults are not specified for following keys diff --git a/src/java/org/apache/hadoop/security/AccessKey.java b/src/java/org/apache/hadoop/security/AccessKey.java deleted file mode 100644 index 81b6383381e22..0000000000000 --- a/src/java/org/apache/hadoop/security/AccessKey.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.security; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import javax.crypto.Mac; - -import org.apache.hadoop.io.Text; -import org.apache.hadoop.io.Writable; -import org.apache.hadoop.io.WritableUtils; - -/** - * Key used for generating and verifying access tokens - */ -public class AccessKey implements Writable { - private long keyID; - private Text key; - private long expiryDate; - private Mac mac; - - public AccessKey() { - this(0L, new Text(), 0L); - } - - public AccessKey(long keyID, Text key, long expiryDate) { - this.keyID = keyID; - this.key = key; - this.expiryDate = expiryDate; - } - - public long getKeyID() { - return keyID; - } - - public Text getKey() { - return key; - } - - public long getExpiryDate() { - return expiryDate; - } - - public Mac getMac() { - return mac; - } - - public void setMac(Mac mac) { - this.mac = mac; - } - - static boolean isEqual(Object a, Object b) { - return a == null ? b == null : a.equals(b); - } - - /** {@inheritDoc} */ - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof AccessKey) { - AccessKey that = (AccessKey) obj; - return this.keyID == that.keyID && isEqual(this.key, that.key) - && this.expiryDate == that.expiryDate; - } - return false; - } - - /** {@inheritDoc} */ - public int hashCode() { - return key == null ? 0 : key.hashCode(); - } - - // /////////////////////////////////////////////// - // Writable - // /////////////////////////////////////////////// - /** - */ - public void write(DataOutput out) throws IOException { - WritableUtils.writeVLong(out, keyID); - key.write(out); - WritableUtils.writeVLong(out, expiryDate); - } - - /** - */ - public void readFields(DataInput in) throws IOException { - keyID = WritableUtils.readVLong(in); - key.readFields(in); - expiryDate = WritableUtils.readVLong(in); - } -} \ No newline at end of file diff --git a/src/java/org/apache/hadoop/security/AccessToken.java b/src/java/org/apache/hadoop/security/AccessToken.java deleted file mode 100644 index 5a5d9a72f46cb..0000000000000 --- a/src/java/org/apache/hadoop/security/AccessToken.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.security; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.hadoop.io.Text; -import org.apache.hadoop.io.Writable; - -public class AccessToken implements Writable { - public static final AccessToken DUMMY_TOKEN = new AccessToken(); - private Text tokenID; - private Text tokenAuthenticator; - - public AccessToken() { - this(new Text(), new Text()); - } - - public AccessToken(Text tokenID, Text tokenAuthenticator) { - this.tokenID = tokenID; - this.tokenAuthenticator = tokenAuthenticator; - } - - public Text getTokenID() { - return tokenID; - } - - public Text getTokenAuthenticator() { - return tokenAuthenticator; - } - - static boolean isEqual(Object a, Object b) { - return a == null ? b == null : a.equals(b); - } - - /** {@inheritDoc} */ - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof AccessToken) { - AccessToken that = (AccessToken) obj; - return isEqual(this.tokenID, that.tokenID) - && isEqual(this.tokenAuthenticator, that.tokenAuthenticator); - } - return false; - } - - /** {@inheritDoc} */ - public int hashCode() { - return tokenAuthenticator == null ? 0 : tokenAuthenticator.hashCode(); - } - - // /////////////////////////////////////////////// - // Writable - // /////////////////////////////////////////////// - /** - */ - public void write(DataOutput out) throws IOException { - tokenID.write(out); - tokenAuthenticator.write(out); - } - - /** - */ - public void readFields(DataInput in) throws IOException { - tokenID.readFields(in); - tokenAuthenticator.readFields(in); - } - -} \ No newline at end of file diff --git a/src/java/org/apache/hadoop/security/AccessTokenHandler.java b/src/java/org/apache/hadoop/security/AccessTokenHandler.java deleted file mode 100644 index 97166dcb9665f..0000000000000 --- a/src/java/org/apache/hadoop/security/AccessTokenHandler.java +++ /dev/null @@ -1,312 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.security; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.security.GeneralSecurityException; -import java.security.SecureRandom; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import javax.crypto.KeyGenerator; -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.io.Text; -import org.apache.hadoop.io.WritableUtils; -import org.apache.hadoop.fs.CommonConfigurationKeys; - -/** - * AccessTokenHandler can be instantiated in 2 modes, master mode and slave - * mode. Master can generate new access keys and export access keys to slaves, - * while slaves can only import and use access keys received from master. Both - * master and slave can generate and verify access tokens. Typically, master - * mode is used by NN and slave mode is used by DN. - */ -public class AccessTokenHandler { - private static final Log LOG = LogFactory.getLog(AccessTokenHandler.class); - public static final String STRING_ENABLE_ACCESS_TOKEN = - CommonConfigurationKeys.FS_ACCESS_TOKEN_ENABLE_KEY; - public static final String STRING_ACCESS_KEY_UPDATE_INTERVAL = - CommonConfigurationKeys.FS_ACCESS_KEY_UPDATE_INTERVAL_KEY; - public static final String STRING_ACCESS_TOKEN_LIFETIME = - CommonConfigurationKeys.FS_ACCESS_TOKEN_LIFETIME_KEY; - - - private final boolean isMaster; - /* - * keyUpdateInterval is the interval that NN updates its access keys. It - * should be set long enough so that all live DN's and Balancer should have - * sync'ed their access keys with NN at least once during each interval. - */ - private final long keyUpdateInterval; - private long tokenLifetime; - private long serialNo = new SecureRandom().nextLong(); - private KeyGenerator keyGen; - private AccessKey currentKey; - private AccessKey nextKey; - private Map<Long, AccessKey> allKeys; - - public static enum AccessMode { - READ, WRITE, COPY, REPLACE - }; - - /** - * Constructor - * - * @param isMaster - * @param keyUpdateInterval - * @param tokenLifetime - * @throws IOException - */ - public AccessTokenHandler(boolean isMaster, long keyUpdateInterval, - long tokenLifetime) throws IOException { - this.isMaster = isMaster; - this.keyUpdateInterval = keyUpdateInterval; - this.tokenLifetime = tokenLifetime; - this.allKeys = new HashMap<Long, AccessKey>(); - if (isMaster) { - try { - generateKeys(); - initMac(currentKey); - } catch (GeneralSecurityException e) { - throw (IOException) new IOException( - "Failed to create AccessTokenHandler").initCause(e); - } - } - } - - /** Initialize access keys */ - private synchronized void generateKeys() throws NoSuchAlgorithmException { - keyGen = KeyGenerator.getInstance("HmacSHA1"); - /* - * Need to set estimated expiry dates for currentKey and nextKey so that if - * NN crashes, DN can still expire those keys. NN will stop using the newly - * generated currentKey after the first keyUpdateInterval, however it may - * still be used by DN and Balancer to generate new tokens before they get a - * chance to sync their keys with NN. Since we require keyUpdInterval to be - * long enough so that all live DN's and Balancer will sync their keys with - * NN at least once during the period, the estimated expiry date for - * currentKey is set to now() + 2 * keyUpdateInterval + tokenLifetime. - * Similarly, the estimated expiry date for nextKey is one keyUpdateInterval - * more. - */ - serialNo++; - currentKey = new AccessKey(serialNo, new Text(keyGen.generateKey() - .getEncoded()), System.currentTimeMillis() + 2 * keyUpdateInterval - + tokenLifetime); - serialNo++; - nextKey = new AccessKey(serialNo, new Text(keyGen.generateKey() - .getEncoded()), System.currentTimeMillis() + 3 * keyUpdateInterval - + tokenLifetime); - allKeys.put(currentKey.getKeyID(), currentKey); - allKeys.put(nextKey.getKeyID(), nextKey); - } - - /** Initialize Mac function */ - private synchronized void initMac(AccessKey key) throws IOException { - try { - Mac mac = Mac.getInstance("HmacSHA1"); - mac.init(new SecretKeySpec(key.getKey().getBytes(), "HmacSHA1")); - key.setMac(mac); - } catch (GeneralSecurityException e) { - throw (IOException) new IOException( - "Failed to initialize Mac for access key, keyID=" + key.getKeyID()) - .initCause(e); - } - } - - /** Export access keys, only to be used in master mode */ - public synchronized ExportedAccessKeys exportKeys() { - if (!isMaster) - return null; - if (LOG.isDebugEnabled()) - LOG.debug("Exporting access keys"); - return new ExportedAccessKeys(true, keyUpdateInterval, tokenLifetime, - currentKey, allKeys.values().toArray(new AccessKey[0])); - } - - private synchronized void removeExpiredKeys() { - long now = System.currentTimeMillis(); - for (Iterator<Map.Entry<Long, AccessKey>> it = allKeys.entrySet() - .iterator(); it.hasNext();) { - Map.Entry<Long, AccessKey> e = it.next(); - if (e.getValue().getExpiryDate() < now) { - it.remove(); - } - } - } - - /** - * Set access keys, only to be used in slave mode - */ - public synchronized void setKeys(ExportedAccessKeys exportedKeys) - throws IOException { - if (isMaster || exportedKeys == null) - return; - LOG.info("Setting access keys"); - removeExpiredKeys(); - this.currentKey = exportedKeys.getCurrentKey(); - initMac(currentKey); - AccessKey[] receivedKeys = exportedKeys.getAllKeys(); - for (int i = 0; i < receivedKeys.length; i++) { - if (receivedKeys[i] == null) - continue; - this.allKeys.put(receivedKeys[i].getKeyID(), receivedKeys[i]); - } - } - - /** - * Update access keys, only to be used in master mode - */ - public synchronized void updateKeys() throws IOException { - if (!isMaster) - return; - LOG.info("Updating access keys"); - removeExpiredKeys(); - // set final expiry date of retiring currentKey - allKeys.put(currentKey.getKeyID(), new AccessKey(currentKey.getKeyID(), - currentKey.getKey(), System.currentTimeMillis() + keyUpdateInterval - + tokenLifetime)); - // update the estimated expiry date of new currentKey - currentKey = new AccessKey(nextKey.getKeyID(), nextKey.getKey(), System - .currentTimeMillis() - + 2 * keyUpdateInterval + tokenLifetime); - initMac(currentKey); - allKeys.put(currentKey.getKeyID(), currentKey); - // generate a new nextKey - serialNo++; - nextKey = new AccessKey(serialNo, new Text(keyGen.generateKey() - .getEncoded()), System.currentTimeMillis() + 3 * keyUpdateInterval - + tokenLifetime); - allKeys.put(nextKey.getKeyID(), nextKey); - } - - /** Check if token is well formed */ - private synchronized boolean verifyToken(long keyID, AccessToken token) - throws IOException { - AccessKey key = allKeys.get(keyID); - if (key == null) { - LOG.warn("Access key for keyID=" + keyID + " doesn't exist."); - return false; - } - if (key.getMac() == null) { - initMac(key); - } - Text tokenID = token.getTokenID(); - Text authenticator = new Text(key.getMac().doFinal(tokenID.getBytes())); - return authenticator.equals(token.getTokenAuthenticator()); - } - - /** Generate an access token for current user */ - public AccessToken generateToken(long blockID, EnumSet<AccessMode> modes) - throws IOException { - UserGroupInformation ugi = UserGroupInformation.getCurrentUGI(); - String userID = (ugi == null ? null : ugi.getUserName()); - return generateToken(userID, blockID, modes); - } - - /** Generate an access token for a specified user */ - public synchronized AccessToken generateToken(String userID, long blockID, - EnumSet<AccessMode> modes) throws IOException { - if (LOG.isDebugEnabled()) { - LOG.debug("Generating access token for user=" + userID + ", blockID=" - + blockID + ", access modes=" + modes + ", keyID=" - + currentKey.getKeyID()); - } - if (modes == null || modes.isEmpty()) - throw new IOException("access modes can't be null or empty"); - ByteArrayOutputStream buf = new ByteArrayOutputStream(4096); - DataOutputStream out = new DataOutputStream(buf); - WritableUtils.writeVLong(out, System.currentTimeMillis() + tokenLifetime); - WritableUtils.writeVLong(out, currentKey.getKeyID()); - WritableUtils.writeString(out, userID); - WritableUtils.writeVLong(out, blockID); - WritableUtils.writeVInt(out, modes.size()); - for (AccessMode aMode : modes) { - WritableUtils.writeEnum(out, aMode); - } - Text tokenID = new Text(buf.toByteArray()); - return new AccessToken(tokenID, new Text(currentKey.getMac().doFinal( - tokenID.getBytes()))); - } - - /** Check if access should be allowed. userID is not checked if null */ - public boolean checkAccess(AccessToken token, String userID, long blockID, - AccessMode mode) throws IOException { - long oExpiry = 0; - long oKeyID = 0; - String oUserID = null; - long oBlockID = 0; - EnumSet<AccessMode> oModes = EnumSet.noneOf(AccessMode.class); - - try { - ByteArrayInputStream buf = new ByteArrayInputStream(token.getTokenID() - .getBytes()); - DataInputStream in = new DataInputStream(buf); - oExpiry = WritableUtils.readVLong(in); - oKeyID = WritableUtils.readVLong(in); - oUserID = WritableUtils.readString(in); - oBlockID = WritableUtils.readVLong(in); - int length = WritableUtils.readVInt(in); - for (int i = 0; i < length; ++i) { - oModes.add(WritableUtils.readEnum(in, AccessMode.class)); - } - } catch (IOException e) { - throw (IOException) new IOException( - "Unable to parse access token for user=" + userID + ", blockID=" - + blockID + ", access mode=" + mode).initCause(e); - } - if (LOG.isDebugEnabled()) { - LOG.debug("Verifying access token for user=" + userID + ", blockID=" - + blockID + ", access mode=" + mode + ", keyID=" + oKeyID); - } - return (userID == null || userID.equals(oUserID)) && oBlockID == blockID - && !isExpired(oExpiry) && oModes.contains(mode) - && verifyToken(oKeyID, token); - } - - private static boolean isExpired(long expiryDate) { - return System.currentTimeMillis() > expiryDate; - } - - /** check if a token is expired. for unit test only. - * return true when token is expired, false otherwise */ - static boolean isTokenExpired(AccessToken token) throws IOException { - ByteArrayInputStream buf = new ByteArrayInputStream(token.getTokenID() - .getBytes()); - DataInputStream in = new DataInputStream(buf); - long expiryDate = WritableUtils.readVLong(in); - return isExpired(expiryDate); - } - - /** set token lifetime. for unit test only */ - synchronized void setTokenLifetime(long tokenLifetime) { - this.tokenLifetime = tokenLifetime; - } -} diff --git a/src/java/org/apache/hadoop/security/ExportedAccessKeys.java b/src/java/org/apache/hadoop/security/ExportedAccessKeys.java deleted file mode 100644 index e5ab2934b4bc8..0000000000000 --- a/src/java/org/apache/hadoop/security/ExportedAccessKeys.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.security; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.Arrays; - -import org.apache.hadoop.io.Writable; -import org.apache.hadoop.io.WritableFactories; -import org.apache.hadoop.io.WritableFactory; - -/** - * Object for passing access keys - */ -public class ExportedAccessKeys implements Writable { - public static final ExportedAccessKeys DUMMY_KEYS = new ExportedAccessKeys(); - private boolean isAccessTokenEnabled; - private long keyUpdateInterval; - private long tokenLifetime; - private AccessKey currentKey; - private AccessKey[] allKeys; - - public ExportedAccessKeys() { - this(false, 0, 0, new AccessKey(), new AccessKey[0]); - } - - ExportedAccessKeys(boolean isAccessTokenEnabled, long keyUpdateInterval, - long tokenLifetime, AccessKey currentKey, AccessKey[] allKeys) { - this.isAccessTokenEnabled = isAccessTokenEnabled; - this.keyUpdateInterval = keyUpdateInterval; - this.tokenLifetime = tokenLifetime; - this.currentKey = currentKey; - this.allKeys = allKeys; - } - - public boolean isAccessTokenEnabled() { - return isAccessTokenEnabled; - } - - public long getKeyUpdateInterval() { - return keyUpdateInterval; - } - - public long getTokenLifetime() { - return tokenLifetime; - } - - public AccessKey getCurrentKey() { - return currentKey; - } - - public AccessKey[] getAllKeys() { - return allKeys; - } - - static boolean isEqual(Object a, Object b) { - return a == null ? b == null : a.equals(b); - } - - /** {@inheritDoc} */ - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (obj instanceof ExportedAccessKeys) { - ExportedAccessKeys that = (ExportedAccessKeys) obj; - return this.isAccessTokenEnabled == that.isAccessTokenEnabled - && this.keyUpdateInterval == that.keyUpdateInterval - && this.tokenLifetime == that.tokenLifetime - && isEqual(this.currentKey, that.currentKey) - && Arrays.equals(this.allKeys, that.allKeys); - } - return false; - } - - /** {@inheritDoc} */ - public int hashCode() { - return currentKey == null ? 0 : currentKey.hashCode(); - } - - // /////////////////////////////////////////////// - // Writable - // /////////////////////////////////////////////// - static { // register a ctor - WritableFactories.setFactory(ExportedAccessKeys.class, - new WritableFactory() { - public Writable newInstance() { - return new ExportedAccessKeys(); - } - }); - } - - /** - */ - public void write(DataOutput out) throws IOException { - out.writeBoolean(isAccessTokenEnabled); - out.writeLong(keyUpdateInterval); - out.writeLong(tokenLifetime); - currentKey.write(out); - out.writeInt(allKeys.length); - for (int i = 0; i < allKeys.length; i++) { - allKeys[i].write(out); - } - } - - /** - */ - public void readFields(DataInput in) throws IOException { - isAccessTokenEnabled = in.readBoolean(); - keyUpdateInterval = in.readLong(); - tokenLifetime = in.readLong(); - currentKey.readFields(in); - this.allKeys = new AccessKey[in.readInt()]; - for (int i = 0; i < allKeys.length; i++) { - allKeys[i] = new AccessKey(); - allKeys[i].readFields(in); - } - } - -} \ No newline at end of file diff --git a/src/java/org/apache/hadoop/security/InvalidAccessTokenException.java b/src/java/org/apache/hadoop/security/InvalidAccessTokenException.java deleted file mode 100644 index eabce15ea3b13..0000000000000 --- a/src/java/org/apache/hadoop/security/InvalidAccessTokenException.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.security; - -import java.io.IOException; - -/** - * Access token verification failed. - */ -public class InvalidAccessTokenException extends IOException { - private static final long serialVersionUID = 168L; - - public InvalidAccessTokenException() { - super(); - } - - public InvalidAccessTokenException(String msg) { - super(msg); - } -} diff --git a/src/test/core/org/apache/hadoop/security/SecurityTestUtil.java b/src/test/core/org/apache/hadoop/security/SecurityTestUtil.java deleted file mode 100644 index d6a30fcad10da..0000000000000 --- a/src/test/core/org/apache/hadoop/security/SecurityTestUtil.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.security; - -import java.io.IOException; - -/** Utilities for security tests */ -public class SecurityTestUtil { - - /** - * check if an access token is expired. return true when token is expired, - * false otherwise - */ - public static boolean isAccessTokenExpired(AccessToken token) - throws IOException { - return AccessTokenHandler.isTokenExpired(token); - } - - /** - * set access token lifetime. - */ - public static void setAccessTokenLifetime(AccessTokenHandler handler, - long tokenLifetime) { - handler.setTokenLifetime(tokenLifetime); - } - -} diff --git a/src/test/core/org/apache/hadoop/security/TestAccessToken.java b/src/test/core/org/apache/hadoop/security/TestAccessToken.java deleted file mode 100644 index cd3cc4c482a9c..0000000000000 --- a/src/test/core/org/apache/hadoop/security/TestAccessToken.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.hadoop.security; - -import java.util.EnumSet; - -import org.apache.hadoop.io.TestWritable; - -import junit.framework.TestCase; - -/** Unit tests for access tokens */ -public class TestAccessToken extends TestCase { - long accessKeyUpdateInterval = 10 * 60 * 1000; // 10 mins - long accessTokenLifetime = 2 * 60 * 1000; // 2 mins - long blockID1 = 0L; - long blockID2 = 10L; - long blockID3 = -108L; - - /** test Writable */ - public void testWritable() throws Exception { - TestWritable.testWritable(ExportedAccessKeys.DUMMY_KEYS); - AccessTokenHandler handler = new AccessTokenHandler(true, - accessKeyUpdateInterval, accessTokenLifetime); - ExportedAccessKeys keys = handler.exportKeys(); - TestWritable.testWritable(keys); - TestWritable.testWritable(AccessToken.DUMMY_TOKEN); - AccessToken token = handler.generateToken(blockID3, EnumSet - .allOf(AccessTokenHandler.AccessMode.class)); - TestWritable.testWritable(token); - } - - private void tokenGenerationAndVerification(AccessTokenHandler master, - AccessTokenHandler slave) throws Exception { - // single-mode tokens - for (AccessTokenHandler.AccessMode mode : AccessTokenHandler.AccessMode - .values()) { - // generated by master - AccessToken token1 = master.generateToken(blockID1, EnumSet.of(mode)); - assertTrue(master.checkAccess(token1, null, blockID1, mode)); - assertTrue(slave.checkAccess(token1, null, blockID1, mode)); - // generated by slave - AccessToken token2 = slave.generateToken(blockID2, EnumSet.of(mode)); - assertTrue(master.checkAccess(token2, null, blockID2, mode)); - assertTrue(slave.checkAccess(token2, null, blockID2, mode)); - } - // multi-mode tokens - AccessToken mtoken = master.generateToken(blockID3, EnumSet - .allOf(AccessTokenHandler.AccessMode.class)); - for (AccessTokenHandler.AccessMode mode : AccessTokenHandler.AccessMode - .values()) { - assertTrue(master.checkAccess(mtoken, null, blockID3, mode)); - assertTrue(slave.checkAccess(mtoken, null, blockID3, mode)); - } - } - - /** test access key and token handling */ - public void testAccessTokenHandler() throws Exception { - AccessTokenHandler masterHandler = new AccessTokenHandler(true, - accessKeyUpdateInterval, accessTokenLifetime); - AccessTokenHandler slaveHandler = new AccessTokenHandler(false, - accessKeyUpdateInterval, accessTokenLifetime); - ExportedAccessKeys keys = masterHandler.exportKeys(); - slaveHandler.setKeys(keys); - tokenGenerationAndVerification(masterHandler, slaveHandler); - // key updating - masterHandler.updateKeys(); - tokenGenerationAndVerification(masterHandler, slaveHandler); - keys = masterHandler.exportKeys(); - slaveHandler.setKeys(keys); - tokenGenerationAndVerification(masterHandler, slaveHandler); - } - -}
c28831a0bdaaa573bfd6c4e837183eb5197876fb
hadoop
YARN-280. RM does not reject app submission with- invalid tokens (Daryn Sharp via tgraves)--git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1425085 13f79535-47bb-0310-9956-ffa450edef68-
c
https://github.com/apache/hadoop
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 6e2cca1006e7a..683008d0fec85 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -224,6 +224,9 @@ Release 0.23.6 - UNRELEASED YARN-266. RM and JHS Web UIs are blank because AppsBlock is not escaping string properly (Ravi Prakash via jlowe) + YARN-280. RM does not reject app submission with invalid tokens + (Daryn Sharp via tgraves) + Release 0.23.5 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java index e5abbb7ede9ec..9232190ba3bec 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java @@ -276,21 +276,26 @@ public synchronized void addApplication( Collection <Token<?>> tokens = ts.getAllTokens(); long now = System.currentTimeMillis(); + // find tokens for renewal, but don't add timers until we know + // all renewable tokens are valid + Set<DelegationTokenToRenew> dtrs = new HashSet<DelegationTokenToRenew>(); for(Token<?> token : tokens) { // first renew happens immediately if (token.isManaged()) { DelegationTokenToRenew dtr = new DelegationTokenToRenew(applicationId, token, getConfig(), now, shouldCancelAtEnd); - - addTokenToList(dtr); - - setTimerForTokenRenewal(dtr, true); - if (LOG.isDebugEnabled()) { - LOG.debug("Registering token for renewal for:" + - " service = " + token.getService() + - " for appId = " + applicationId); - } + renewToken(dtr); + dtrs.add(dtr); + } + } + for (DelegationTokenToRenew dtr : dtrs) { + addTokenToList(dtr); + setTimerForTokenRenewal(dtr); + if (LOG.isDebugEnabled()) { + LOG.debug("Registering token for renewal for:" + + " service = " + dtr.token.getService() + + " for appId = " + applicationId); } } } @@ -315,22 +320,13 @@ public synchronized void run() { Token<?> token = dttr.token; try { - // need to use doAs so that http can find the kerberos tgt - dttr.expirationDate = UserGroupInformation.getLoginUser() - .doAs(new PrivilegedExceptionAction<Long>(){ - - @Override - public Long run() throws Exception { - return dttr.token.renew(dttr.conf); - } - }); - + renewToken(dttr); if (LOG.isDebugEnabled()) { LOG.debug("Renewing delegation-token for:" + token.getService() + "; new expiration;" + dttr.expirationDate); } - setTimerForTokenRenewal(dttr, false);// set the next one + setTimerForTokenRenewal(dttr);// set the next one } catch (Exception e) { LOG.error("Exception renewing token" + token + ". Not rescheduled", e); removeFailedDelegationToken(dttr); @@ -347,19 +343,12 @@ public synchronized boolean cancel() { /** * set task to renew the token */ - private - void setTimerForTokenRenewal(DelegationTokenToRenew token, - boolean firstTime) throws IOException { + private void setTimerForTokenRenewal(DelegationTokenToRenew token) + throws IOException { // calculate timer time - long now = System.currentTimeMillis(); - long renewIn; - if(firstTime) { - renewIn = now; - } else { - long expiresIn = (token.expirationDate - now); - renewIn = now + expiresIn - expiresIn/10; // little bit before the expiration - } + long expiresIn = token.expirationDate - System.currentTimeMillis(); + long renewIn = token.expirationDate - expiresIn/10; // little bit before the expiration // need to create new task every time TimerTask tTask = new RenewalTimerTask(token); @@ -368,6 +357,24 @@ void setTimerForTokenRenewal(DelegationTokenToRenew token, renewalTimer.schedule(token.timerTask, new Date(renewIn)); } + // renew a token + private void renewToken(final DelegationTokenToRenew dttr) + throws IOException { + // need to use doAs so that http can find the kerberos tgt + // NOTE: token renewers should be responsible for the correct UGI! + try { + dttr.expirationDate = UserGroupInformation.getLoginUser().doAs( + new PrivilegedExceptionAction<Long>(){ + @Override + public Long run() throws Exception { + return dttr.token.renew(dttr.conf); + } + }); + } catch (InterruptedException e) { + throw new IOException(e); + } + } + // cancel a token private void cancelToken(DelegationTokenToRenew t) { if(t.shouldCancelAtEnd) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java index 1c3614e46df37..ad127a9264d9d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java @@ -357,6 +357,27 @@ public void testDTRenewal () throws Exception { } } + @Test + public void testInvalidDTWithAddApplication() throws Exception { + MyFS dfs = (MyFS)FileSystem.get(conf); + LOG.info("dfs="+(Object)dfs.hashCode() + ";conf="+conf.hashCode()); + + MyToken token = dfs.getDelegationToken(new Text("user1")); + token.cancelToken(); + + Credentials ts = new Credentials(); + ts.addToken(token.getKind(), token); + + // register the tokens for renewal + ApplicationId appId = BuilderUtils.newApplicationId(0, 0); + try { + delegationTokenRenewer.addApplication(appId, ts, true); + fail("App submission with a cancelled token should have failed"); + } catch (InvalidToken e) { + // expected + } + } + /** * Basic idea of the test: * 1. register a token for 2 seconds with no cancel at the end
90deb516a68158f753312ce15273ed52f8eb398f
Vala
glib-2.0: set has_type_id = false for int16 and uint16
c
https://github.com/GNOME/vala/
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index e8d6839fd5..b864b34eaa 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -351,7 +351,7 @@ public struct uint8 { } [SimpleType] -[CCode (cname = "gint16", cheader_filename = "glib.h", default_value = "0", type_signature = "n")] +[CCode (cname = "gint16", cheader_filename = "glib.h", default_value = "0", type_signature = "n", has_type_id = false)] [IntegerType (rank = 4, min = -32768, max = 32767)] public struct int16 { [CCode (cname = "G_MININT16")] @@ -386,7 +386,7 @@ public struct int16 { } [SimpleType] -[CCode (cname = "guint16", cheader_filename = "glib.h", default_value = "0U", type_signature = "q")] +[CCode (cname = "guint16", cheader_filename = "glib.h", default_value = "0U", type_signature = "q", has_type_id = false)] [IntegerType (rank = 5, min = 0, max = 65535)] public struct uint16 { [CCode (cname = "0U")]
52fe6310a02d23419c6adada88354fa068347dd8
kotlin
Fix breakpoints in inline functions in libraries--
c
https://github.com/JetBrains/kotlin
diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt index 8b26972d48623..073b0073c55c7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt @@ -48,6 +48,8 @@ import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils import org.jetbrains.kotlin.idea.decompiler.JetClsFile import org.jetbrains.kotlin.idea.findUsages.toSearchTarget import org.jetbrains.kotlin.idea.search.usagesSearch.DefaultSearchHelper +import org.jetbrains.kotlin.idea.search.usagesSearch.FunctionUsagesSearchHelper +import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearch import org.jetbrains.kotlin.idea.search.usagesSearch.search import org.jetbrains.kotlin.idea.util.DebuggerUtils import org.jetbrains.kotlin.idea.util.application.runReadAction @@ -353,7 +355,10 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult } if (isInLibrary) { - val elementAtForLibraryFile = getElementToCreateTypeMapperForLibraryFile(notPositionedElement) + val elementAtForLibraryFile = + if (element is JetDeclaration) element + else PsiTreeUtil.getParentOfType(element, javaClass<JetDeclaration>()) + assert(elementAtForLibraryFile != null) { "Couldn't find element at breakpoint for library file " + file.getName() + (if (notPositionedElement == null) "" else ", notPositionedElement = " + notPositionedElement.getElementTextWithContext()) @@ -430,9 +435,11 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult InlineUtil.isInline(typeMapper.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiElement)) ) { val project = myDebugProcess.getProject() - val usagesSearchTarget = FindUsagesOptions(project).toSearchTarget(psiElement, true) + val options = FindUsagesOptions(project) + options.isSearchForTextOccurrences = false + val usagesSearchTarget = options.toSearchTarget(psiElement, true) - val usagesSearchRequest = DefaultSearchHelper<JetNamedFunction>(true).newRequest(usagesSearchTarget) + val usagesSearchRequest = FunctionUsagesSearchHelper(skipImports = true).newRequest(usagesSearchTarget) usagesSearchRequest.search().forEach { val psiElement = it.getElement() if (psiElement is JetElement) { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/PositionManagerLibraryClassFileSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/PositionManagerLibraryClassFileSearcher.kt index ceace2ba737b0..ab7d0c3e7e890 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/PositionManagerLibraryClassFileSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/PositionManagerLibraryClassFileSearcher.kt @@ -51,13 +51,7 @@ private val LOG = Logger.getInstance("org.jetbrains.kotlin.idea.debugger") * 2. find all descriptors with same signature, if there is one - return it * 3. else -> return null, because it means that there is more than one function with same signature in project */ -fun findPackagePartInternalNameForLibraryFile(elementAt: JetElement): String? { - val topLevelDeclaration = PsiTreeUtil.getTopmostParentOfType(elementAt, javaClass<JetDeclaration>()) - if (topLevelDeclaration == null) { - reportError(elementAt, null) - return null - } - +fun findPackagePartInternalNameForLibraryFile(topLevelDeclaration: JetDeclaration): String? { val packagePartFile = findPackagePartFileNamesForElement(topLevelDeclaration).singleOrNull() if (packagePartFile != null) return packagePartFile diff --git a/idea/src/org/jetbrains/kotlin/idea/util/DebuggerUtils.java b/idea/src/org/jetbrains/kotlin/idea/util/DebuggerUtils.java index e88ea3ce09a1e..58add37c3ab53 100644 --- a/idea/src/org/jetbrains/kotlin/idea/util/DebuggerUtils.java +++ b/idea/src/org/jetbrains/kotlin/idea/util/DebuggerUtils.java @@ -99,7 +99,7 @@ public Boolean invoke(JetFile file) { public Boolean invoke(JetFile file) { Integer startLineOffset = CodeInsightUtils.getStartLineOffset(file, lineNumber); assert startLineOffset != null : "Cannot find start line offset for file " + file.getName() + ", line " + lineNumber; - JetElement elementAt = PsiTreeUtil.getParentOfType(file.findElementAt(startLineOffset), JetElement.class); + JetDeclaration elementAt = PsiTreeUtil.getParentOfType(file.findElementAt(startLineOffset), JetDeclaration.class); return elementAt != null && className.getInternalName().equals(DebuggerPackage.findPackagePartInternalNameForLibraryFile(elementAt)); } diff --git a/idea/testData/debugger/customLibraryForTinyApp/inlineFunInLibrary/inlineFunInLibrary.kt b/idea/testData/debugger/customLibraryForTinyApp/inlineFunInLibrary/inlineFunInLibrary.kt new file mode 100644 index 0000000000000..f5ef1ab10e7e3 --- /dev/null +++ b/idea/testData/debugger/customLibraryForTinyApp/inlineFunInLibrary/inlineFunInLibrary.kt @@ -0,0 +1,5 @@ +package customLib.inlineFunInLibrary + +public inline fun inlineFun(f: () -> Unit) { + 1 + 1 +} diff --git a/idea/testData/debugger/tinyApp/outs/breakpointInInlineFun.out b/idea/testData/debugger/tinyApp/outs/breakpointInInlineFun.out new file mode 100644 index 0000000000000..dcf05d1088e25 --- /dev/null +++ b/idea/testData/debugger/tinyApp/outs/breakpointInInlineFun.out @@ -0,0 +1,7 @@ +LineBreakpoint created at inlineFunInLibrary.kt:3 +!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! breakpointInInlineFun.BreakpointInInlineFunPackage +Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' +inlineFunInLibrary.kt:4 +Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' + +Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/breakpointInInlineFun.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/breakpointInInlineFun.kt new file mode 100644 index 0000000000000..027b287037e81 --- /dev/null +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/breakpointInInlineFun.kt @@ -0,0 +1,9 @@ +package breakpointInInlineFun + +import customLib.inlineFunInLibrary.* + +fun main(args: Array<String>) { + inlineFun { } +} + +// ADDITIONAL_BREAKPOINT: inlineFunInLibrary.kt:public inline fun inlineFun \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java index 2bc965afdc23f..e23dc6ce26549 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluateExpressionTestGenerated.java @@ -61,6 +61,12 @@ public void testBoxParam() throws Exception { doSingleBreakpointTest(fileName); } + @TestMetadata("breakpointInInlineFun.kt") + public void testBreakpointInInlineFun() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/breakpointInInlineFun.kt"); + doSingleBreakpointTest(fileName); + } + @TestMetadata("callableBug.kt") public void testCallableBug() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/callableBug.kt");
d5d80e1722cef18e5a8b629eb3f75bd846818624
tapiji
Define gitignore rules for project binaries and local settings. Cleans up plug-in projects by removing `.setting` folders. For preventing the checkin of binary data and local settings, a `.gitignore` file has been specified. (cherry picked from commit 604412a22d0e7fc0480489a76affe0c55d885d06) Conflicts: .gitignore org.eclipse.babel.editor/.settings/org.eclipse.jdt.core.prefs
p
https://github.com/tapiji/tapiji
diff --git a/.gitignore b/.gitignore index 31578696..90beae66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,5 @@ -/*/.project /*/.metadata /*/bin/** /*/tmp/** -/*/tmp/**/* -*.tmp -*.bak -*.swp -*~.nib /*/local.properties -.classpath /*/.settings/ -.loadpath - diff --git a/org.eclipse.babel.editor/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.babel.editor/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f4f31ebe..00000000 --- a/org.eclipse.babel.editor/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Sat Jun 14 14:50:52 CEST 2008 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/org.eclipse.babel.tapiji.tools.core.ui/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.babel.tapiji.tools.core.ui/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8fba0220..00000000 --- a/org.eclipse.babel.tapiji.tools.core.ui/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Fri Mar 16 22:52:15 CET 2012 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.eclipse.babel.tapiji.tools.core/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.babel.tapiji.tools.core/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index a28e1c9f..00000000 --- a/org.eclipse.babel.tapiji.tools.core/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Mon Aug 23 17:53:06 CEST 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.eclipse.babel.tapiji.tools.core/.settings/org.eclipse.pde.core.prefs b/org.eclipse.babel.tapiji.tools.core/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 5186f827..00000000 --- a/org.eclipse.babel.tapiji.tools.core/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sat Jan 01 13:54:32 CET 2011 -eclipse.preferences.version=1 -resolve.requirebundle=false diff --git a/org.eclipse.babel.tapiji.tools.java.ui/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.babel.tapiji.tools.java.ui/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index ede70f69..00000000 --- a/org.eclipse.babel.tapiji.tools.java.ui/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Sun Jan 30 10:03:19 CET 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.eclipse.babel.tapiji.tools.java/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.babel.tapiji.tools.java/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c537b630..00000000 --- a/org.eclipse.babel.tapiji.tools.java/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.babel.tapiji.tools.rbmanager/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 519aa0e2..00000000 --- a/org.eclipse.babel.tapiji.tools.rbmanager/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Wed Jul 20 11:00:34 CEST 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6
b9e1d6c698b589368f4a155134e8b2ba00608dc8
hbase
HBASE-3653 : Parallelize Server Requests on HBase- Client--git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1082648 13f79535-47bb-0310-9956-ffa450edef68-
p
https://github.com/apache/hbase
diff --git a/CHANGES.txt b/CHANGES.txt index 21c60235fb3a..70366e5a2e90 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -77,6 +77,7 @@ Release 0.91.0 - Unreleased Export (Subbu M Iyer via Stack) HBASE-3440 Clean out load_table.rb and make sure all roads lead to completebulkload tool (Vidhyashankar Venkataraman via Stack) + HBASE-3653 Parallelize Server Requests on HBase Client TASK HBASE-3559 Move report of split to master OFF the heartbeat channel diff --git a/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java b/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java index 3d2c5ea8b89d..644de1fa6bd3 100644 --- a/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java +++ b/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java @@ -240,6 +240,7 @@ static class HConnectionImplementation implements HConnection { private final Map<String, HRegionInterface> servers = new ConcurrentHashMap<String, HRegionInterface>(); + private final ConcurrentHashMap<String, String> connectionLock = new ConcurrentHashMap<String, String>(); /** * Map of table to table {@link HRegionLocation}s. The table key is made @@ -941,21 +942,30 @@ public HRegionInterface getHRegionConnection( getMaster(); } HRegionInterface server; - synchronized (this.servers) { - // See if we already have a connection - server = this.servers.get(regionServer.toString()); - if (server == null) { // Get a connection - try { - server = (HRegionInterface)HBaseRPC.waitForProxy( - serverInterfaceClass, HRegionInterface.VERSION, - regionServer.getInetSocketAddress(), this.conf, - this.maxRPCAttempts, this.rpcTimeout, this.rpcTimeout); - } catch (RemoteException e) { - LOG.warn("RemoteException connecting to RS", e); - // Throw what the RemoteException was carrying. - throw RemoteExceptionHandler.decodeRemoteException(e); + String rsName = regionServer.toString(); + // See if we already have a connection (common case) + server = this.servers.get(rsName); + if (server == null) { + // create a unique lock for this RS (if necessary) + this.connectionLock.putIfAbsent(rsName, rsName); + // get the RS lock + synchronized (this.connectionLock.get(rsName)) { + // do one more lookup in case we were stalled above + server = this.servers.get(rsName); + if (server == null) { + try { + // definitely a cache miss. establish an RPC for this RS + server = (HRegionInterface) HBaseRPC.waitForProxy( + serverInterfaceClass, HRegionInterface.VERSION, + regionServer.getInetSocketAddress(), this.conf, + this.maxRPCAttempts, this.rpcTimeout, this.rpcTimeout); + this.servers.put(rsName, server); + } catch (RemoteException e) { + LOG.warn("RemoteException connecting to RS", e); + // Throw what the RemoteException was carrying. + throw RemoteExceptionHandler.decodeRemoteException(e); + } } - this.servers.put(regionServer.toString(), server); } } return server;
610115b44e10e5046b62a7dfad06dde18e0f83e7
camel
added explicit generics to avoid possible- compiler wierdness in the DSL like we had yesterday where the compiler- decided to use Object rather than ProcessorType in some DSL expressions--git-svn-id: https://svn.apache.org/repos/asf/activemq/camel/trunk@585089 13f79535-47bb-0310-9956-ffa450edef68-
p
https://github.com/apache/camel
diff --git a/camel-core/src/main/java/org/apache/camel/model/BeanRef.java b/camel-core/src/main/java/org/apache/camel/model/BeanRef.java index cfd52e806d841..6a1dabd8c1bc7 100644 --- a/camel-core/src/main/java/org/apache/camel/model/BeanRef.java +++ b/camel-core/src/main/java/org/apache/camel/model/BeanRef.java @@ -33,7 +33,7 @@ */ @XmlRootElement(name = "bean") @XmlAccessorType(XmlAccessType.FIELD) -public class BeanRef extends OutputType { +public class BeanRef extends OutputType<ProcessorType> { @XmlAttribute(required = true) private String ref; @XmlAttribute(required = false) diff --git a/camel-core/src/main/java/org/apache/camel/model/CatchType.java b/camel-core/src/main/java/org/apache/camel/model/CatchType.java index dd345a526e27d..0195cf6d6ba83 100644 --- a/camel-core/src/main/java/org/apache/camel/model/CatchType.java +++ b/camel-core/src/main/java/org/apache/camel/model/CatchType.java @@ -36,7 +36,7 @@ */ @XmlRootElement(name = "catch") @XmlAccessorType(XmlAccessType.FIELD) -public class CatchType extends ProcessorType { +public class CatchType extends ProcessorType<ProcessorType> { @XmlElementRef private List<InterceptorType> interceptors = new ArrayList<InterceptorType>(); @XmlElement(name = "exception") diff --git a/camel-core/src/main/java/org/apache/camel/model/FinallyType.java b/camel-core/src/main/java/org/apache/camel/model/FinallyType.java index 6f7a695b53c05..68175959c65cc 100644 --- a/camel-core/src/main/java/org/apache/camel/model/FinallyType.java +++ b/camel-core/src/main/java/org/apache/camel/model/FinallyType.java @@ -28,7 +28,7 @@ */ @XmlRootElement(name = "finally") @XmlAccessorType(XmlAccessType.FIELD) -public class FinallyType extends OutputType { +public class FinallyType extends OutputType<ProcessorType> { @Override public String toString() { return "Finally[" + getOutputs() + "]"; diff --git a/camel-core/src/main/java/org/apache/camel/model/MarshalType.java b/camel-core/src/main/java/org/apache/camel/model/MarshalType.java index 43d4405a7b9ab..2e09d13312d0e 100644 --- a/camel-core/src/main/java/org/apache/camel/model/MarshalType.java +++ b/camel-core/src/main/java/org/apache/camel/model/MarshalType.java @@ -41,7 +41,7 @@ */ @XmlRootElement(name = "marshal") @XmlAccessorType(XmlAccessType.FIELD) -public class MarshalType extends OutputType { +public class MarshalType extends OutputType<ProcessorType> { @XmlAttribute(required = false) private String ref; // TODO cannot use @XmlElementRef as it doesn't allow optional properties diff --git a/camel-core/src/main/java/org/apache/camel/model/OtherwiseType.java b/camel-core/src/main/java/org/apache/camel/model/OtherwiseType.java index 4dd7913018bca..4d8134f9f8581 100644 --- a/camel-core/src/main/java/org/apache/camel/model/OtherwiseType.java +++ b/camel-core/src/main/java/org/apache/camel/model/OtherwiseType.java @@ -28,7 +28,7 @@ */ @XmlRootElement(name = "otherwise") @XmlAccessorType(XmlAccessType.FIELD) -public class OtherwiseType extends OutputType { +public class OtherwiseType extends OutputType<ProcessorType> { @Override public String toString() { diff --git a/camel-core/src/main/java/org/apache/camel/model/PolicyRef.java b/camel-core/src/main/java/org/apache/camel/model/PolicyRef.java index f9d12b011e9a8..df4afea632e67 100644 --- a/camel-core/src/main/java/org/apache/camel/model/PolicyRef.java +++ b/camel-core/src/main/java/org/apache/camel/model/PolicyRef.java @@ -31,7 +31,7 @@ */ @XmlRootElement(name = "policy") @XmlAccessorType(XmlAccessType.FIELD) -public class PolicyRef extends OutputType { +public class PolicyRef extends OutputType<ProcessorType> { @XmlAttribute(required = true) private String ref; @XmlTransient diff --git a/camel-core/src/main/java/org/apache/camel/model/ProceedType.java b/camel-core/src/main/java/org/apache/camel/model/ProceedType.java index 1cc5933f6444c..16bd3bdb3b4c2 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ProceedType.java +++ b/camel-core/src/main/java/org/apache/camel/model/ProceedType.java @@ -31,9 +31,9 @@ */ @XmlRootElement(name = "proceed") @XmlAccessorType(XmlAccessType.FIELD) -public class ProceedType extends ProcessorType { +public class ProceedType extends ProcessorType<ProcessorType> { - public List<ProcessorType> getOutputs() { + public List<ProcessorType<?>> getOutputs() { return Collections.EMPTY_LIST; } diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorRef.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorRef.java index 1b48b8e9c38b6..3517c0489e6ee 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ProcessorRef.java +++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorRef.java @@ -30,7 +30,7 @@ */ @XmlRootElement(name = "process") @XmlAccessorType(XmlAccessType.FIELD) -public class ProcessorRef extends OutputType { +public class ProcessorRef extends OutputType<ProcessorType> { @XmlAttribute(required = true) private String ref; @XmlTransient diff --git a/camel-core/src/main/java/org/apache/camel/model/ThreadType.java b/camel-core/src/main/java/org/apache/camel/model/ThreadType.java index f88298adff365..1292763745fc7 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ThreadType.java +++ b/camel-core/src/main/java/org/apache/camel/model/ThreadType.java @@ -40,7 +40,7 @@ */ @XmlRootElement(name = "thread") @XmlAccessorType(XmlAccessType.FIELD) -public class ThreadType extends ProcessorType { +public class ThreadType extends ProcessorType<ProcessorType> { @XmlAttribute private int coreSize = 1; @@ -57,7 +57,7 @@ public class ThreadType extends ProcessorType { @XmlAttribute private long stackSize; @XmlElementRef - private List<ProcessorType> outputs = new ArrayList<ProcessorType>(); + private List<ProcessorType<?>> outputs = new ArrayList<ProcessorType<?>>(); @XmlTransient private BlockingQueue<Runnable> taskQueue; @@ -84,7 +84,7 @@ public List getInterceptors() { } @Override - public List getOutputs() { + public List<ProcessorType<?>> getOutputs() { return outputs; } diff --git a/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java b/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java index 0abb2d2e631af..ed3f52fce9e5d 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java +++ b/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java @@ -34,7 +34,7 @@ */ @XmlRootElement(name = "throttler") @XmlAccessorType(XmlAccessType.FIELD) -public class ThrottlerType extends ProcessorType { +public class ThrottlerType extends ProcessorType<ProcessorType> { @XmlAttribute private Long maximumRequestsPerPeriod; @XmlAttribute @@ -42,7 +42,7 @@ public class ThrottlerType extends ProcessorType { @XmlElementRef private List<InterceptorType> interceptors = new ArrayList<InterceptorType>(); @XmlElementRef - private List<ProcessorType> outputs = new ArrayList<ProcessorType>(); + private List<ProcessorType<?>> outputs = new ArrayList<ProcessorType<?>>(); public ThrottlerType() { } @@ -106,11 +106,11 @@ public void setInterceptors(List<InterceptorType> interceptors) { this.interceptors = interceptors; } - public List<ProcessorType> getOutputs() { + public List<ProcessorType<?>> getOutputs() { return outputs; } - public void setOutputs(List<ProcessorType> outputs) { + public void setOutputs(List<ProcessorType<?>> outputs) { this.outputs = outputs; } } diff --git a/camel-core/src/main/java/org/apache/camel/model/ToType.java b/camel-core/src/main/java/org/apache/camel/model/ToType.java index 483f7ec1cd5b3..b9736b15394d3 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ToType.java +++ b/camel-core/src/main/java/org/apache/camel/model/ToType.java @@ -40,7 +40,7 @@ */ @XmlRootElement(name = "to") @XmlAccessorType(XmlAccessType.FIELD) -public class ToType extends ProcessorType { +public class ToType extends ProcessorType<ProcessorType> { @XmlAttribute private String uri; @XmlAttribute @@ -121,7 +121,7 @@ public void setEndpoint(Endpoint endpoint) { this.endpoint = endpoint; } - public List<ProcessorType> getOutputs() { + public List<ProcessorType<?>> getOutputs() { return Collections.EMPTY_LIST; } diff --git a/camel-core/src/main/java/org/apache/camel/model/UnmarshalType.java b/camel-core/src/main/java/org/apache/camel/model/UnmarshalType.java index 90d49b96fbe6f..b17bf67437941 100644 --- a/camel-core/src/main/java/org/apache/camel/model/UnmarshalType.java +++ b/camel-core/src/main/java/org/apache/camel/model/UnmarshalType.java @@ -40,7 +40,7 @@ */ @XmlRootElement(name = "unmarshal") @XmlAccessorType(XmlAccessType.FIELD) -public class UnmarshalType extends OutputType { +public class UnmarshalType extends OutputType<ProcessorType> { @XmlAttribute(required = false) private String ref; // TODO cannot use @XmlElementRef as it doesn't allow optional properties
2c9238fa348bd6fc2d51b8cb29e1c435713a4652
camel
CAMEL-1134 make the ZipDataFormat Stream friendly--git-svn-id: https://svn.apache.org/repos/asf/activemq/camel/trunk@722005 13f79535-47bb-0310-9956-ffa450edef68-
p
https://github.com/apache/camel
diff --git a/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java b/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java index 4219687ecf68c..c2b0f466fcf9b 100644 --- a/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java +++ b/camel-core/src/main/java/org/apache/camel/converter/IOConverter.java @@ -120,13 +120,23 @@ public static StringReader toReader(String text) { } @Converter - public static InputStream toInputStream(String text) { + public static InputStream toInputStream(String text, Exchange exchange) { + if (exchange != null) { + String charsetName = exchange.getProperty(Exchange.CHARSET_NAME, String.class); + if (charsetName != null) { + try { + return toInputStream(text.getBytes(charsetName)); + } catch (UnsupportedEncodingException e) { + LOG.warn("Can't convert the String into the bytes with the charset " + charsetName, e); + } + } + } return toInputStream(text.getBytes()); } @Converter - public static InputStream toInputStream(BufferedReader buffer) throws IOException { - return toInputStream(toString(buffer)); + public static InputStream toInputStream(BufferedReader buffer, Exchange exchange) throws IOException { + return toInputStream(toString(buffer), exchange); } @Converter @@ -270,14 +280,14 @@ public static byte[] toBytes(InputStream stream) throws IOException { return bos.toByteArray(); } - protected static void copy(InputStream stream, ByteArrayOutputStream bos) throws IOException { + public static void copy(InputStream stream, OutputStream os) throws IOException { byte[] data = new byte[4096]; - int read = stream.read(data); - while (read != -1) { - bos.write(data, 0, read); + int read = stream.read(data); + while (read != -1) { + os.write(data, 0, read); read = stream.read(data); } - bos.flush(); + os.flush(); } protected static String toString(Source source, Properties props) throws TransformerException, IOException { diff --git a/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java b/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java index 5dd6c1bc42092..21ccae791bebb 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java +++ b/camel-core/src/main/java/org/apache/camel/impl/ZipDataFormat.java @@ -18,15 +18,12 @@ import java.io.ByteArrayOutputStream; import java.io.InputStream; -import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.zip.Deflater; -import java.util.zip.Inflater; - -import javax.xml.bind.annotation.XmlAttribute; +import java.util.zip.DeflaterOutputStream; +import java.util.zip.InflaterInputStream; import org.apache.camel.Exchange; -import org.apache.camel.Message; import org.apache.camel.converter.IOConverter; import org.apache.camel.spi.DataFormat; @@ -43,47 +40,43 @@ public ZipDataFormat(int compressionLevel) { this.compressionLevel = compressionLevel; } - public void marshal(Exchange exchange, Object graph, OutputStream stream) + public void marshal(Exchange exchange, Object body, OutputStream stream) throws Exception { - - // Retrieve the message body as byte array - byte[] input = (byte[]) exchange.getIn().getBody(byte[].class); - - // Create a Message Deflater - Deflater deflater = new Deflater(compressionLevel); - deflater.setInput(input); - deflater.finish(); + InputStream is; + if (body instanceof InputStream) { + is = (InputStream)body; + } + is = exchange.getIn().getBody(InputStream.class); + if (is == null) { + throw new IllegalArgumentException("Can't get the inputstream for ZipDataFormat mashalling"); + } + + DeflaterOutputStream zipOutput = new DeflaterOutputStream(stream, new Deflater(compressionLevel)); // Compress the data - byte[] output = new byte[INITIALBYTEARRAYSIZE]; - while (!deflater.finished()) { - int count = deflater.deflate(output); - stream.write(output, 0, count); - } + IOConverter.copy(is, zipOutput); + zipOutput.close(); } public Object unmarshal(Exchange exchange, InputStream stream) throws Exception { - - // Retrieve the message body as byte array - byte[] input = (byte[]) exchange.getIn().getBody(byte[].class); - // Create a Message Inflater - Inflater inflater = new Inflater(); - inflater.setInput(input); - + InputStream is = stream; + if (is == null) { + exchange.getIn().getBody(InputStream.class); + } + if (is == null) { + throw new IllegalArgumentException("Can't get the inputStream for ZipDataFormat unmashalling"); + } + + InflaterInputStream unzipInput = new InflaterInputStream(is); + // Create an expandable byte array to hold the inflated data - ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); - // Inflate the compressed data - byte[] buf = new byte[INITIALBYTEARRAYSIZE]; - while (!inflater.finished()) { - int count = inflater.inflate(buf); - bos.write(buf, 0, count); - } + IOConverter.copy(unzipInput, bos); - // Return the inflated data return bos.toByteArray(); }
2e16bba9234ca33b0c408d79ea5511760bb8174e
dozermapper$dozer
refactoring; generalizing mapping loading functionality;
p
https://github.com/dozermapper/dozer
diff --git a/src/main/java/org/dozer/loader/CustomMappingsLoader.java b/src/main/java/org/dozer/loader/CustomMappingsLoader.java index 764f30167..e925c0f71 100644 --- a/src/main/java/org/dozer/loader/CustomMappingsLoader.java +++ b/src/main/java/org/dozer/loader/CustomMappingsLoader.java @@ -27,7 +27,6 @@ import org.dozer.converters.CustomConverterDescription; import org.dozer.loader.xml.MappingFileReader; import org.dozer.loader.xml.XMLParserFactory; -import org.dozer.util.DozerConstants; import org.dozer.util.InitLogger; import org.dozer.util.MappingUtils; import org.dozer.util.MappingValidator; @@ -53,41 +52,19 @@ public class CustomMappingsLoader { private final MappingFileReader mappingFileReader = new MappingFileReader(XMLParserFactory.getInstance()); public LoadMappingsResult load(List<String> mappingFiles) { - ClassMappings customMappings = new ClassMappings(); - ListOrderedSet customConverterDescriptions = ListOrderedSet.decorate(new ArrayList<CustomConverterDescription>()); - Configuration globalConfiguration = null; - List<MappingFileData> mappingFileDataList = new ArrayList<MappingFileData>(); - if (mappingFiles != null && mappingFiles.size() > 0) { - InitLogger.log(log, "Using the following xml files to load custom mappings for the bean mapper instance: " + mappingFiles); - for (String mappingFileName : mappingFiles) { - InitLogger.log(log, "Trying to find xml mapping file: " + mappingFileName); - URL url = MappingValidator.validateURL(DozerConstants.DEFAULT_PATH_ROOT + mappingFileName); - InitLogger.log(log, "Using URL [" + url + "] to load custom xml mappings"); - MappingFileData mappingFileData = mappingFileReader.read(url); - InitLogger.log(log, "Successfully loaded custom xml mappings from URL: [" + url + "]"); + + List<MappingFileData> mappingFileDataList = loadFromFiles(mappingFiles); - if (mappingFileData.getConfiguration() != null) { - //Only allow 1 global configuration - if (globalConfiguration != null) { - MappingUtils - .throwMappingException("More than one global configuration found. " - + "Only one global configuration block (<configuration></configuration>) can be specified across all mapping files. " - + "You need to consolidate all global configuration blocks into a single one."); - } - globalConfiguration = mappingFileData.getConfiguration(); - } - mappingFileDataList.add(mappingFileData); - } - } + Configuration globalConfiguration = findConfiguration(mappingFileDataList); - //If global configuration was not specified, use defaults - if (globalConfiguration == null) { - globalConfiguration = new Configuration(); - } + ClassMappings customMappings = new ClassMappings(); + ListOrderedSet customConverterDescriptions = ListOrderedSet.decorate(new ArrayList<CustomConverterDescription>()); // Decorate the raw ClassMap objects and create ClassMap "prime" instances for (MappingFileData mappingFileData : mappingFileDataList) { - customMappings.addAll(mappingsParser.processMappings(mappingFileData.getClassMaps(), globalConfiguration)); + List<ClassMap> classMaps = mappingFileData.getClassMaps(); + ClassMappings customMappingsPrime = mappingsParser.processMappings(classMaps, globalConfiguration); + customMappings.addAll(customMappingsPrime); } // Add default mappings using matching property names if wildcard policy @@ -113,4 +90,44 @@ public LoadMappingsResult load(List<String> mappingFiles) { } return new LoadMappingsResult(customMappings, globalConfiguration); } + + private List<MappingFileData> loadFromFiles(List<String> mappingFiles) { + List<MappingFileData> mappingFileDataList = new ArrayList<MappingFileData>(); + if (mappingFiles != null && mappingFiles.size() > 0) { + InitLogger.log(log, "Using the following xml files to load custom mappings for the bean mapper instance: " + mappingFiles); + for (String mappingFileName : mappingFiles) { + InitLogger.log(log, "Trying to find xml mapping file: " + mappingFileName); + URL url = MappingValidator.validateURL(mappingFileName); + InitLogger.log(log, "Using URL [" + url + "] to load custom xml mappings"); + MappingFileData mappingFileData = mappingFileReader.read(url); + InitLogger.log(log, "Successfully loaded custom xml mappings from URL: [" + url + "]"); + + mappingFileDataList.add(mappingFileData); + } + } + return mappingFileDataList; + } + + private Configuration findConfiguration(List<MappingFileData> mappingFileDataList) { + Configuration globalConfiguration = null; + for (MappingFileData mappingFileData : mappingFileDataList) { + if (mappingFileData.getConfiguration() != null) { + //Only allow 1 global configuration + if (globalConfiguration != null) { + MappingUtils + .throwMappingException("More than one global configuration found. " + + "Only one global configuration block (<configuration></configuration>) can be specified across all mapping files. " + + "You need to consolidate all global configuration blocks into a single one."); + } + globalConfiguration = mappingFileData.getConfiguration(); + } + } + + //If global configuration was not specified, use defaults + if (globalConfiguration == null) { + globalConfiguration = new Configuration(); + } + + return globalConfiguration; + } } diff --git a/src/main/java/org/dozer/loader/MappingBuilder.java b/src/main/java/org/dozer/loader/DozerBuilder.java similarity index 74% rename from src/main/java/org/dozer/loader/MappingBuilder.java rename to src/main/java/org/dozer/loader/DozerBuilder.java index 778b20a6d..b6d883540 100644 --- a/src/main/java/org/dozer/loader/MappingBuilder.java +++ b/src/main/java/org/dozer/loader/DozerBuilder.java @@ -35,102 +35,109 @@ import org.dozer.fieldmap.GenericFieldMap; import org.dozer.fieldmap.HintContainer; import org.dozer.fieldmap.MapFieldMap; +import org.dozer.util.DozerConstants; import org.dozer.util.MappingUtils; import java.util.ArrayList; import java.util.List; /** + * Builder API for achivieng the same effect as custom Xml mappings. + * Is intended to be used from application to prepare repetetive mappings programmatically. + * <p/> + * Note that some of the fail-fast checks from Xml validation has not yet been ported. + * Responsibility on filling all mandatory attributes is left to API user. + * <p/> * Not thread safe * * @author dmitry.buzdin */ -public class MappingBuilder { +public class DozerBuilder { MappingFileData data = new MappingFileData(); - private final List<MappingDefinitionBuilder> mappingBuilders = new ArrayList<MappingDefinitionBuilder>(); + private final List<MappingBuilder> mappingBuilders = new ArrayList<MappingBuilder>(); public MappingFileData build() { - for (MappingDefinitionBuilder builder : mappingBuilders) { + for (MappingBuilder builder : mappingBuilders) { builder.build(); } return data; } - public MappingConfigurationBuilder configuration() { + public ConfigurationBuilder configuration() { Configuration configuration = new Configuration(); configuration.setCustomConverters(new CustomConverterContainer()); configuration.setCopyByReferences(new CopyByReferenceContainer()); configuration.setAllowedExceptions(new AllowedExceptionContainer()); data.setConfiguration(configuration); - return new MappingConfigurationBuilder(configuration); + return new ConfigurationBuilder(configuration); } - public MappingDefinitionBuilder mapping() { + public MappingBuilder mapping() { Configuration configuration = data.getConfiguration(); ClassMap classMap = new ClassMap(configuration); data.getClassMaps().add(classMap); - MappingDefinitionBuilder mappingDefinitionBuilder = new MappingDefinitionBuilder(classMap); + MappingBuilder mappingDefinitionBuilder = new MappingBuilder(classMap); mappingBuilders.add(mappingDefinitionBuilder); return mappingDefinitionBuilder; } - public static class MappingDefinitionBuilder { + public static class MappingBuilder { private ClassMap classMap; - private final List<FieldContainerBuider> fieldBuilders = new ArrayList<FieldContainerBuider>(); + private final List<FieldBuider> fieldBuilders = new ArrayList<FieldBuider>(); - public MappingDefinitionBuilder(ClassMap classMap) { + public MappingBuilder(ClassMap classMap) { this.classMap = classMap; } - public MappingDefinitionBuilder dateFormat(String dateFormat) { + public MappingBuilder dateFormat(String dateFormat) { classMap.setDateFormat(dateFormat); return this; } - public MappingDefinitionBuilder mapNull(boolean value) { + public MappingBuilder mapNull(boolean value) { classMap.setMapNull(value); return this; } - public MappingDefinitionBuilder mapEmptyString(boolean value) { + public MappingBuilder mapEmptyString(boolean value) { classMap.setMapEmptyString(value); return this; } // TODO Load class ? - public MappingDefinitionBuilder beanFactory(String typeName) { + public MappingBuilder beanFactory(String typeName) { classMap.setBeanFactory(typeName); return this; } - public MappingDefinitionBuilder relationshipType(RelationshipType type) { + public MappingBuilder relationshipType(RelationshipType type) { classMap.setRelationshipType(type); return this; } - public MappingDefinitionBuilder wildcard(Boolean value) { + public MappingBuilder wildcard(Boolean value) { classMap.setWildcard(value); return this; } - public MappingDefinitionBuilder trimStrings(Boolean value) { + public MappingBuilder trimStrings(Boolean value) { classMap.setTrimStrings(value); return this; } - public MappingDefinitionBuilder stopOnErrors(Boolean value) { + public MappingBuilder stopOnErrors(Boolean value) { classMap.setStopOnErrors(value); return this; } - public MappingDefinitionBuilder mapId(String id) { + public MappingBuilder mapId(String id) { classMap.setMapId(id); return this; } - public MappingDefinitionBuilder type(MappingDirection type) { + public MappingBuilder type(MappingDirection type) { classMap.setType(type); return this; } @@ -159,40 +166,40 @@ public ClassDefinitionBuilder classB(Class type) { return new ClassDefinitionBuilder(classDefinition); } - public ExcludeFieldBuilder fieldExclude() { + public FieldExclusionBuilder fieldExclude() { ExcludeFieldMap excludeFieldMap = new ExcludeFieldMap(classMap); - ExcludeFieldBuilder builder = new ExcludeFieldBuilder(excludeFieldMap); + FieldExclusionBuilder builder = new FieldExclusionBuilder(excludeFieldMap); fieldBuilders.add(builder); return builder; } - public FieldMapBuilder field() { - FieldMapBuilder builder = new FieldMapBuilder(classMap); + public FieldMappingBuilder field() { + FieldMappingBuilder builder = new FieldMappingBuilder(classMap); fieldBuilders.add(builder); return builder; } public void build() { - for (FieldContainerBuider builder : fieldBuilders) { + for (FieldBuider builder : fieldBuilders) { builder.build(); } } } - public interface FieldContainerBuider { - FieldBuilder a(String name, String type); + public interface FieldBuider { + FieldDefinitionBuilder a(String name, String type); - FieldBuilder b(String name, String type); + FieldDefinitionBuilder b(String name, String type); void build(); } - public static class ExcludeFieldBuilder implements FieldContainerBuider { + public static class FieldExclusionBuilder implements FieldBuider { private ExcludeFieldMap fieldMap; - public ExcludeFieldBuilder(ExcludeFieldMap fieldMap) { + public FieldExclusionBuilder(ExcludeFieldMap fieldMap) { this.fieldMap = fieldMap; } @@ -200,16 +207,16 @@ public void type(MappingDirection type) { fieldMap.setType(type); } - public FieldBuilder a(String name, String type) { + public FieldDefinitionBuilder a(String name, String type) { DozerField field = prepareField(name, type); fieldMap.setSrcField(field); - return new FieldBuilder(field); + return new FieldDefinitionBuilder(field); } - public FieldBuilder b(String name, String type) { + public FieldDefinitionBuilder b(String name, String type) { DozerField field = prepareField(name, type); fieldMap.setDestField(field); - return new FieldBuilder(field); + return new FieldDefinitionBuilder(field); } @@ -220,7 +227,7 @@ public void build() { } - public static class FieldMapBuilder implements FieldContainerBuider { + public static class FieldMappingBuilder implements FieldBuider { private ClassMap classMap; private DozerField srcField; @@ -239,91 +246,91 @@ public static class FieldMapBuilder implements FieldContainerBuider { private String customConverterParam; private boolean copyByReferenceSet; - public FieldMapBuilder(ClassMap classMap) { + public FieldMappingBuilder(ClassMap classMap) { this.classMap = classMap; } - public FieldBuilder a(String name, String type) { - DozerField field = MappingBuilder.prepareField(name, type); + public FieldDefinitionBuilder a(String name, String type) { + DozerField field = DozerBuilder.prepareField(name, type); this.srcField = field; - return new FieldBuilder(field); + return new FieldDefinitionBuilder(field); } - public FieldBuilder b(String name, String type) { + public FieldDefinitionBuilder b(String name, String type) { DozerField field = prepareField(name, type); this.destField = field; - return new FieldBuilder(field); + return new FieldDefinitionBuilder(field); } - public FieldMapBuilder type(MappingDirection type) { + public FieldMappingBuilder type(MappingDirection type) { this.type = type; return this; } - public FieldMapBuilder relationshipType(RelationshipType relationshipType) { + public FieldMappingBuilder relationshipType(RelationshipType relationshipType) { this.relationshipType = relationshipType; return this; } - public FieldMapBuilder removeOrphans(boolean value) { + public FieldMappingBuilder removeOrphans(boolean value) { this.removeOrphans = value; return this; } - public FieldMapBuilder srcHintContainer(String hint) { + public FieldMappingBuilder srcHintContainer(String hint) { HintContainer hintContainer = new HintContainer(); hintContainer.setHintName(hint); this.srcHintContainer = hintContainer; return this; } - public FieldMapBuilder destHintContainer(String hint) { + public FieldMappingBuilder destHintContainer(String hint) { HintContainer hintContainer = new HintContainer(); hintContainer.setHintName(hint); this.destHintContainer = hintContainer; return this; } - public FieldMapBuilder srcDeepIndexHintContainer(String hint) { + public FieldMappingBuilder srcDeepIndexHintContainer(String hint) { HintContainer hintContainer = new HintContainer(); hintContainer.setHintName(hint); this.srcDeepIndexHintContainer = hintContainer; return this; } - public FieldMapBuilder destDeepIndexHintContainer(String hint) { + public FieldMappingBuilder destDeepIndexHintContainer(String hint) { HintContainer hintContainer = new HintContainer(); hintContainer.setHintName(hint); this.destDeepIndexHintContainer = hintContainer; return this; } - public FieldMapBuilder copyByReference(boolean value) { + public FieldMappingBuilder copyByReference(boolean value) { this.copyByReferenceSet = true; this.copyByReference = value; return this; } - public FieldMapBuilder mapId(String attribute) { + public FieldMappingBuilder mapId(String attribute) { this.mapId = attribute; return this; } - public FieldMapBuilder customConverter(Class<? extends CustomConverter> type) { + public FieldMappingBuilder customConverter(Class<? extends CustomConverter> type) { return customConverter(type.getName()); } - - public FieldMapBuilder customConverter(String typeName) { + + public FieldMappingBuilder customConverter(String typeName) { this.customConverter = typeName; return this; } - public FieldMapBuilder customConverterId(String attribute) { + public FieldMappingBuilder customConverterId(String attribute) { this.customConverterId = attribute; return this; } - public FieldMapBuilder customConverterParam(String attribute) { + public FieldMappingBuilder customConverterParam(String attribute) { this.customConverterParam = attribute; return this; } @@ -365,10 +372,10 @@ public void build() { } - public static class FieldBuilder { + public static class FieldDefinitionBuilder { private DozerField field; - public FieldBuilder(DozerField field) { + public FieldDefinitionBuilder(DozerField field) { this.field = field; } @@ -487,42 +494,46 @@ public ClassDefinitionBuilder mapEmptyString(Boolean value) { } - public static class MappingConfigurationBuilder { + public static class ConfigurationBuilder { private Configuration configuration; private CustomConverterDescription converterDescription; - public MappingConfigurationBuilder(Configuration configuration) { + public ConfigurationBuilder(Configuration configuration) { this.configuration = configuration; } - public MappingConfigurationBuilder stopOnErrors(Boolean value) { + public ConfigurationBuilder stopOnErrors(Boolean value) { configuration.setStopOnErrors(value); return this; } - public MappingConfigurationBuilder dateFormat(String format) { + public ConfigurationBuilder dateFormat(String format) { configuration.setDateFormat(format); return this; } - public MappingConfigurationBuilder wildcard(Boolean value) { + public ConfigurationBuilder wildcard(Boolean value) { configuration.setWildcard(value); return this; } - public MappingConfigurationBuilder trimStrings(Boolean value) { + public ConfigurationBuilder trimStrings(Boolean value) { configuration.setTrimStrings(value); return this; } - public MappingConfigurationBuilder relationshipType(RelationshipType value) { - configuration.setRelationshipType(value); + public ConfigurationBuilder relationshipType(RelationshipType value) { + if (value == null) { + configuration.setRelationshipType(DozerConstants.DEFAULT_RELATIONSHIP_TYPE_POLICY); + } else { + configuration.setRelationshipType(value); + } return this; } - public MappingConfigurationBuilder beanFactory(String name) { + public ConfigurationBuilder beanFactory(String name) { configuration.setBeanFactory(name); return this; } @@ -540,19 +551,19 @@ public CustomConverterBuilder customConverter(Class type) { return new CustomConverterBuilder(converterDescription); } - public MappingConfigurationBuilder copyByReference(String typeMask) { + public ConfigurationBuilder copyByReference(String typeMask) { CopyByReference copyByReference = new CopyByReference(typeMask); configuration.getCopyByReferences().add(copyByReference); return this; } - public MappingConfigurationBuilder allowedException(String type) { + public ConfigurationBuilder allowedException(String type) { Class<?> exceptionType = MappingUtils.loadClass(type); return allowedException(exceptionType); } // TODO Restrict with generic - public MappingConfigurationBuilder allowedException(Class type) { + public ConfigurationBuilder allowedException(Class type) { if (!RuntimeException.class.isAssignableFrom(type)) { MappingUtils.throwMappingException("allowed-exception Type must extend java.lang.RuntimeException: " + type.getName()); diff --git a/src/main/java/org/dozer/loader/MappingsSource.java b/src/main/java/org/dozer/loader/MappingsSource.java new file mode 100644 index 000000000..8f91c2bc1 --- /dev/null +++ b/src/main/java/org/dozer/loader/MappingsSource.java @@ -0,0 +1,30 @@ +/* + * Copyright 2005-2009 the original author or authors. + * + * 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 org.dozer.loader; + +import org.dozer.classmap.MappingFileData; + +/** + * Source of mapping definition. Mappings could be provided in various ways, + * either from Xml document or programmatically. + * + * @author dmitry.buzdin + */ +public interface MappingsSource { + + MappingFileData load(); + +} diff --git a/src/main/java/org/dozer/loader/api/ApiLoader.java b/src/main/java/org/dozer/loader/api/ApiLoader.java new file mode 100644 index 000000000..8af3802ae --- /dev/null +++ b/src/main/java/org/dozer/loader/api/ApiLoader.java @@ -0,0 +1,30 @@ +/* + * Copyright 2005-2009 the original author or authors. + * + * 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 org.dozer.loader.api; + +import org.dozer.classmap.MappingFileData; +import org.dozer.loader.MappingsSource; + +/** + * @author dmitry.buzdin + */ +public class ApiLoader implements MappingsSource { + + public MappingFileData load() { + return new MappingFileData(); + } + +} diff --git a/src/main/java/org/dozer/loader/dsl/Dummy.java b/src/main/java/org/dozer/loader/dsl/Dummy.java deleted file mode 100644 index 1b282741d..000000000 --- a/src/main/java/org/dozer/loader/dsl/Dummy.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.dozer.loader.dsl; - -/** - * @author dmitry.buzdin - */ -public class Dummy { -} diff --git a/src/main/java/org/dozer/loader/xml/MappingFileReader.java b/src/main/java/org/dozer/loader/xml/MappingFileReader.java index 1302708f0..a768c56ae 100644 --- a/src/main/java/org/dozer/loader/xml/MappingFileReader.java +++ b/src/main/java/org/dozer/loader/xml/MappingFileReader.java @@ -18,6 +18,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.dozer.classmap.MappingFileData; +import org.dozer.loader.MappingsSource; import org.dozer.util.MappingUtils; import org.dozer.util.ResourceLoader; import org.w3c.dom.Document; @@ -57,10 +58,10 @@ public MappingFileData read(URL url) { stream = url.openStream(); Document document = documentBuilder.parse(stream); - XMLParser parser = new XMLParser(); - result = parser.parse(document); + MappingsSource parser = new XMLParser(document); + result = parser.load(); } catch (Throwable e) { - log.error("Error while loading dozer mapping file url: [" + url + "] : " + e); + log.error("Error while loading dozer mapping file url: [" + url + "]", e); MappingUtils.throwMappingException(e); } finally { try { diff --git a/src/main/java/org/dozer/loader/xml/XMLParser.java b/src/main/java/org/dozer/loader/xml/XMLParser.java index 751f1a00a..c4bc9e10e 100644 --- a/src/main/java/org/dozer/loader/xml/XMLParser.java +++ b/src/main/java/org/dozer/loader/xml/XMLParser.java @@ -23,21 +23,23 @@ import org.dozer.classmap.MappingDirection; import org.dozer.classmap.MappingFileData; import org.dozer.classmap.RelationshipType; -import org.dozer.loader.MappingBuilder; -import org.dozer.util.DozerConstants; +import org.dozer.loader.DozerBuilder; +import org.dozer.loader.MappingsSource; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** - * Internal class that parses a raw custom xml mapping file into raw ClassMap objects. Only intended for internal use. + * Internal class that parses a raw custom xml mapping file into ClassMap objects. + * + * Only intended for internal use. * * @author garsombke.franz * @author johnsen.knut-erik * @author dmitry.buzdin */ -public class XMLParser { +public class XMLParser implements MappingsSource { private static final Log log = LogFactory.getLog(XMLParser.class); @@ -89,14 +91,23 @@ public class XMLParser { private static final String CUSTOM_CONVERTER_ID_ATTRIBUTE = "custom-converter-id"; private static final String CUSTOM_CONVERTER_PARAM_ATTRIBUTE = "custom-converter-param"; + private final Document document; + /** - * Builds object representation of mappings based on content of Xml document * * @param document Xml document containing valid mappings definition + */ + public XMLParser(Document document) { + this.document = document; + } + + /** + * Builds object representation of mappings based on content of Xml document + * * @return mapping container */ - public MappingFileData parse(Document document) { - MappingBuilder builder = new MappingBuilder(); + public MappingFileData load() { + DozerBuilder builder = new DozerBuilder(); Element theRoot = document.getDocumentElement(); NodeList nl = theRoot.getChildNodes(); @@ -118,8 +129,8 @@ public MappingFileData parse(Document document) { return builder.build(); } - private void parseMapping(Element ele, MappingBuilder builder) { - MappingBuilder.MappingDefinitionBuilder definitionBuilder = builder.mapping(); + private void parseMapping(Element ele, DozerBuilder builder) { + DozerBuilder.MappingBuilder definitionBuilder = builder.mapping(); if (StringUtils.isNotEmpty(ele.getAttribute(DATE_FORMAT))) { definitionBuilder.dateFormat(ele.getAttribute(DATE_FORMAT)); @@ -163,12 +174,12 @@ private void parseMapping(Element ele, MappingBuilder builder) { debugElement(element); if (CLASS_A_ELEMENT.equals(element.getNodeName())) { String typeName = element.getFirstChild().getNodeValue().trim(); - MappingBuilder.ClassDefinitionBuilder classBuilder = definitionBuilder.classA(typeName); + DozerBuilder.ClassDefinitionBuilder classBuilder = definitionBuilder.classA(typeName); parseClass(element, classBuilder); } if (CLASS_B_ELEMENT.equals(element.getNodeName())) { String typeName = element.getFirstChild().getNodeValue().trim(); - MappingBuilder.ClassDefinitionBuilder classBuilder = definitionBuilder.classB(typeName); + DozerBuilder.ClassDefinitionBuilder classBuilder = definitionBuilder.classB(typeName); parseClass(element, classBuilder); } if (FIELD_ELEMENT.equals(element.getNodeName())) { @@ -180,7 +191,7 @@ private void parseMapping(Element ele, MappingBuilder builder) { } } - private void parseClass(Element element, MappingBuilder.ClassDefinitionBuilder classBuilder) { + private void parseClass(Element element, DozerBuilder.ClassDefinitionBuilder classBuilder) { if (StringUtils.isNotEmpty(element.getAttribute(MAP_GET_METHOD_ATTRIBUTE))) { classBuilder.mapGetMethod(element.getAttribute(MAP_GET_METHOD_ATTRIBUTE)); } @@ -204,8 +215,8 @@ private void parseClass(Element element, MappingBuilder.ClassDefinitionBuilder c } } - private void parseFieldExcludeMap(Element ele, MappingBuilder.MappingDefinitionBuilder definitionBuilder) { - MappingBuilder.ExcludeFieldBuilder fieldMapBuilder = definitionBuilder.fieldExclude(); + private void parseFieldExcludeMap(Element ele, DozerBuilder.MappingBuilder definitionBuilder) { + DozerBuilder.FieldExclusionBuilder fieldMapBuilder = definitionBuilder.fieldExclude(); if (StringUtils.isNotEmpty(ele.getAttribute(TYPE_ATTRIBUTE))) { String mappingDirection = ele.getAttribute(TYPE_ATTRIBUTE); MappingDirection direction = MappingDirection.valueOf(mappingDirection); @@ -222,23 +233,23 @@ private void parseFieldExcludeMap(Element ele, MappingBuilder.MappingDefinitionB } } - private void parseFieldElements(Element element, MappingBuilder.FieldContainerBuider fieldMapBuilder) { + private void parseFieldElements(Element element, DozerBuilder.FieldBuider fieldMapBuilder) { if (A_ELEMENT.equals(element.getNodeName())) { String name = element.getFirstChild().getNodeValue().trim(); String type = element.getAttribute(TYPE_ATTRIBUTE); - MappingBuilder.FieldBuilder fieldBuilder = fieldMapBuilder.a(name, type); + DozerBuilder.FieldDefinitionBuilder fieldBuilder = fieldMapBuilder.a(name, type); parseField(element, fieldBuilder); } if (B_ELEMENT.equals(element.getNodeName())) { String name = element.getFirstChild().getNodeValue().trim(); String type = element.getAttribute(TYPE_ATTRIBUTE); - MappingBuilder.FieldBuilder fieldBuilder = fieldMapBuilder.b(name, type); + DozerBuilder.FieldDefinitionBuilder fieldBuilder = fieldMapBuilder.b(name, type); parseField(element, fieldBuilder); } } - private void parseGenericFieldMap(Element ele, MappingBuilder.MappingDefinitionBuilder definitionBuilder) { - MappingBuilder.FieldMapBuilder fieldMapBuilder = determineFieldMap(definitionBuilder, ele); + private void parseGenericFieldMap(Element ele, DozerBuilder.MappingBuilder definitionBuilder) { + DozerBuilder.FieldMappingBuilder fieldMapBuilder = determineFieldMap(definitionBuilder, ele); if (StringUtils.isNotEmpty(ele.getAttribute(COPY_BY_REFERENCE_ATTRIBUTE))) { fieldMapBuilder.copyByReference(BooleanUtils.toBoolean(ele.getAttribute(COPY_BY_REFERENCE_ATTRIBUTE))); @@ -264,8 +275,8 @@ private void parseGenericFieldMap(Element ele, MappingBuilder.MappingDefinitionB parseFieldMap(ele, fieldMapBuilder); } - private MappingBuilder.FieldMapBuilder determineFieldMap(MappingBuilder.MappingDefinitionBuilder definitionBuilder, Element ele) { - MappingBuilder.FieldMapBuilder fieldMapBuilder = definitionBuilder.field(); + private DozerBuilder.FieldMappingBuilder determineFieldMap(DozerBuilder.MappingBuilder definitionBuilder, Element ele) { + DozerBuilder.FieldMappingBuilder fieldMapBuilder = definitionBuilder.field(); NodeList nl = ele.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { @@ -276,13 +287,13 @@ private MappingBuilder.FieldMapBuilder determineFieldMap(MappingBuilder.MappingD if (A_ELEMENT.equals(element.getNodeName())) { String name = element.getFirstChild().getNodeValue().trim(); String type = element.getAttribute(TYPE_ATTRIBUTE); - MappingBuilder.FieldBuilder builder = fieldMapBuilder.a(name, type); + DozerBuilder.FieldDefinitionBuilder builder = fieldMapBuilder.a(name, type); parseField(element, builder); } if (B_ELEMENT.equals(element.getNodeName())) { String name = element.getFirstChild().getNodeValue().trim(); String type = element.getAttribute(TYPE_ATTRIBUTE); - MappingBuilder.FieldBuilder builder = fieldMapBuilder.b(name, type); + DozerBuilder.FieldDefinitionBuilder builder = fieldMapBuilder.b(name, type); parseField(element, builder); } } @@ -291,7 +302,7 @@ private MappingBuilder.FieldMapBuilder determineFieldMap(MappingBuilder.MappingD return fieldMapBuilder; } - private void parseFieldMap(Element ele, MappingBuilder.FieldMapBuilder fieldMapBuilder) { + private void parseFieldMap(Element ele, DozerBuilder.FieldMappingBuilder fieldMapBuilder) { setRelationshipType(ele, fieldMapBuilder); if (StringUtils.isNotEmpty(ele.getAttribute(REMOVE_ORPHANS))) { @@ -326,7 +337,7 @@ private void parseFieldMap(Element ele, MappingBuilder.FieldMapBuilder fieldMapB } } - private void setRelationshipType(Element ele, MappingBuilder.FieldMapBuilder definitionBuilder) { + private void setRelationshipType(Element ele, DozerBuilder.FieldMappingBuilder definitionBuilder) { RelationshipType relationshipType = null; if (StringUtils.isNotEmpty(ele.getAttribute(RELATIONSHIP_TYPE))) { String relationshipTypeValue = ele.getAttribute(RELATIONSHIP_TYPE); @@ -335,7 +346,7 @@ private void setRelationshipType(Element ele, MappingBuilder.FieldMapBuilder def definitionBuilder.relationshipType(relationshipType); } - private void parseField(Element ele, MappingBuilder.FieldBuilder fieldBuilder) { + private void parseField(Element ele, DozerBuilder.FieldDefinitionBuilder fieldBuilder) { if (StringUtils.isNotEmpty(ele.getAttribute(DATE_FORMAT))) { fieldBuilder.dateFormat(ele.getAttribute(DATE_FORMAT)); } @@ -362,8 +373,8 @@ private void parseField(Element ele, MappingBuilder.FieldBuilder fieldBuilder) { } } - private void parseConfiguration(Element ele, MappingBuilder builder) { - MappingBuilder.MappingConfigurationBuilder configBuilder = builder.configuration(); + private void parseConfiguration(Element ele, DozerBuilder builder) { + DozerBuilder.ConfigurationBuilder configBuilder = builder.configuration(); NodeList nl = ele.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); @@ -384,9 +395,6 @@ private void parseConfiguration(Element ele, MappingBuilder builder) { configBuilder.trimStrings(Boolean.valueOf(nodeValue.trim())); } else if (RELATIONSHIP_TYPE.equals(element.getNodeName())) { RelationshipType relationshipType = RelationshipType.valueOf(nodeValue.trim()); - if (relationshipType == null) { - relationshipType = DozerConstants.DEFAULT_RELATIONSHIP_TYPE_POLICY; - } configBuilder.relationshipType(relationshipType); } else if (BEAN_FACTORY.equals(element.getNodeName())) { configBuilder.beanFactory(nodeValue.trim()); @@ -401,7 +409,7 @@ private void parseConfiguration(Element ele, MappingBuilder builder) { } } - private void parseCustomConverters(Element ele, MappingBuilder.MappingConfigurationBuilder config) { + private void parseCustomConverters(Element ele, DozerBuilder.ConfigurationBuilder config) { NodeList nl = ele.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); @@ -412,7 +420,7 @@ private void parseCustomConverters(Element ele, MappingBuilder.MappingConfigurat if (CONVERTER_ELEMENT.equals(element.getNodeName())) { String converterType = element.getAttribute(TYPE_ATTRIBUTE).trim(); - MappingBuilder.CustomConverterBuilder customConverterBuilder = config.customConverter(converterType); + DozerBuilder.CustomConverterBuilder customConverterBuilder = config.customConverter(converterType); NodeList list = element.getChildNodes(); for (int x = 0; x < list.getLength(); x++) { @@ -438,7 +446,7 @@ private void debugElement(Element element) { } } - private void parseCopyByReferences(Element ele, MappingBuilder.MappingConfigurationBuilder config) { + private void parseCopyByReferences(Element ele, DozerBuilder.ConfigurationBuilder config) { NodeList nl = ele.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); @@ -455,7 +463,7 @@ private void parseCopyByReferences(Element ele, MappingBuilder.MappingConfigurat } } - private void parseAllowedExceptions(Element ele, MappingBuilder.MappingConfigurationBuilder config) { + private void parseAllowedExceptions(Element ele, DozerBuilder.ConfigurationBuilder config) { NodeList nl = ele.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); diff --git a/src/main/java/org/dozer/util/DozerConstants.java b/src/main/java/org/dozer/util/DozerConstants.java index 0d2e1c649..3314e056d 100644 --- a/src/main/java/org/dozer/util/DozerConstants.java +++ b/src/main/java/org/dozer/util/DozerConstants.java @@ -44,7 +44,6 @@ private DozerConstants() {} public static final RelationshipType DEFAULT_RELATIONSHIP_TYPE_POLICY = RelationshipType.CUMULATIVE; public static final String DEFAULT_CONFIG_FILE = "dozer.properties"; public static final String DEFAULT_MAPPING_FILE = "dozerBeanMapping.xml"; - public static final String DEFAULT_PATH_ROOT = ""; public static final boolean DEFAULT_AUTOREGISTER_JMX_BEANS = true; public static final String XSD_NAME = "beanmapping.xsd"; diff --git a/src/test/java/org/dozer/factory/JAXBBeanFactoryTest.java b/src/test/java/org/dozer/factory/JAXBBeanFactoryTest.java index 7ac8a684a..bf9a43082 100644 --- a/src/test/java/org/dozer/factory/JAXBBeanFactoryTest.java +++ b/src/test/java/org/dozer/factory/JAXBBeanFactoryTest.java @@ -1,12 +1,10 @@ package org.dozer.factory; import org.dozer.MappingException; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import org.junit.Before; +import org.junit.Test; /** * @author Vincent Jassogne @@ -21,7 +19,6 @@ public void setUp() throws Exception { } @Test - @Ignore("org.dozer.vo.jaxb child packages missed") public void testCreateBeanForSimpleJaxbClass() { Object obj = factory.createBean(null, null, "org.dozer.vo.jaxb.employee.EmployeeType"); assertNotNull("Object can not be null", obj); @@ -34,7 +31,6 @@ public void testCreateBeanClassNotFoundException() { } @Test - @Ignore("org.dozer.vo.jaxb child packages missed") public void testCreateBeanForInnerJaxbClass() { Object obj = factory.createBean(null, null, "org.dozer.vo.jaxb.employee.EmployeeWithInnerClass$Address"); assertNotNull(obj); @@ -42,7 +38,6 @@ public void testCreateBeanForInnerJaxbClass() { } @Test - @Ignore("org.dozer.vo.jaxb child packages missed") public void testCreateBeanForNestedInnerJaxbClass() { Object obj = factory.createBean(null, null, "org.dozer.vo.jaxb.employee.EmployeeWithInnerClass$Address$State"); assertNotNull(obj); diff --git a/src/test/java/org/dozer/loader/MappingBuilderTest.java b/src/test/java/org/dozer/loader/MappingsBuilderTest.java similarity index 73% rename from src/test/java/org/dozer/loader/MappingBuilderTest.java rename to src/test/java/org/dozer/loader/MappingsBuilderTest.java index a42025112..6827fdc41 100644 --- a/src/test/java/org/dozer/loader/MappingBuilderTest.java +++ b/src/test/java/org/dozer/loader/MappingsBuilderTest.java @@ -23,20 +23,20 @@ /** * @author dmitry.buzdin */ -public class MappingBuilderTest { +public class MappingsBuilderTest { @Test public void testBuild() { - MappingBuilder builder = new MappingBuilder(); + DozerBuilder builder = new DozerBuilder(); MappingFileData result = builder.build(); assertNotNull(result); } @Test public void testGetFieldNameOfIndexedField() { - assertEquals("aaa", MappingBuilder.getFieldNameOfIndexedField("aaa[0]")); - assertEquals("aaa[0].bbb", MappingBuilder.getFieldNameOfIndexedField("aaa[0].bbb[1]")); - assertEquals("aaa[0].bbb[1].ccc", MappingBuilder.getFieldNameOfIndexedField("aaa[0].bbb[1].ccc[2]")); + assertEquals("aaa", DozerBuilder.getFieldNameOfIndexedField("aaa[0]")); + assertEquals("aaa[0].bbb", DozerBuilder.getFieldNameOfIndexedField("aaa[0].bbb[1]")); + assertEquals("aaa[0].bbb[1].ccc", DozerBuilder.getFieldNameOfIndexedField("aaa[0].bbb[1].ccc[2]")); } diff --git a/src/test/java/org/dozer/loader/xml/XMLParserTest.java b/src/test/java/org/dozer/loader/xml/XMLParserTest.java index 565c48eea..a4f21ba68 100644 --- a/src/test/java/org/dozer/loader/xml/XMLParserTest.java +++ b/src/test/java/org/dozer/loader/xml/XMLParserTest.java @@ -19,6 +19,7 @@ import org.dozer.classmap.ClassMap; import org.dozer.classmap.MappingFileData; import org.dozer.fieldmap.FieldMap; +import org.dozer.loader.MappingsSource; import org.dozer.util.ResourceLoader; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -34,7 +35,7 @@ */ public class XMLParserTest extends AbstractDozerTest { - private XMLParser parser = new XMLParser(); + private MappingsSource parser; @Test public void testParse() throws Exception { @@ -42,7 +43,9 @@ public void testParse() throws Exception { URL url = loader.getResource("dozerBeanMapping.xml"); Document document = XMLParserFactory.getInstance().createParser().parse(url.openStream()); - MappingFileData mappings = parser.parse(document); + parser = new XMLParser(document); + + MappingFileData mappings = parser.load(); assertNotNull(mappings); } @@ -56,7 +59,9 @@ public void testParseCustomConverterParam() throws Exception { URL url = loader.getResource("fieldCustomConverterParam.xml"); Document document = XMLParserFactory.getInstance().createParser().parse(url.openStream()); - MappingFileData mappings = parser.parse(document); + parser = new XMLParser(document); + + MappingFileData mappings = parser.load(); assertNotNull("The mappings should not be null", mappings);
2e476072a7ab2b962887e15502e91dcaf7158bf4
tapiji
Adapts product configuration.
p
https://github.com/tapiji/tapiji
diff --git a/org.eclipselabs.tapiji.tools.core/src/org/eclipselabs/tapiji/tools/core/util/PDEUtils.java b/org.eclipselabs.tapiji.tools.core/src/org/eclipselabs/tapiji/tools/core/util/PDEUtils.java new file mode 100644 index 00000000..4f9efbb7 --- /dev/null +++ b/org.eclipselabs.tapiji.tools.core/src/org/eclipselabs/tapiji/tools/core/util/PDEUtils.java @@ -0,0 +1,290 @@ +/* + * Copyright (C) 2007 Uwe Voigt + * + * This file is part of Essiembre ResourceBundle Editor. + * + * Essiembre ResourceBundle Editor is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Essiembre ResourceBundle Editor is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Essiembre ResourceBundle Editor; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + */ +package org.eclipselabs.tapiji.tools.core.util; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.osgi.framework.Constants; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * A class that helps to find fragment and plugin projects. + * + * @author Uwe Voigt (http://sourceforge.net/users/uwe_ewald/) + */ +public class PDEUtils { + + /** Bundle manifest name */ + public static final String OSGI_BUNDLE_MANIFEST = "META-INF/MANIFEST.MF"; //$NON-NLS-1$ + /** Plugin manifest name */ + public static final String PLUGIN_MANIFEST = "plugin.xml"; //$NON-NLS-1$ + /** Fragment manifest name */ + public static final String FRAGMENT_MANIFEST = "fragment.xml"; //$NON-NLS-1$ + + /** + * Returns the plugin-id of the project if it is a plugin project. Else + * null is returned. + * + * @param project the project + * @return the plugin-id or null + */ + public static String getPluginId(IProject project) { + if (project == null) + return null; + IResource manifest = project.findMember(OSGI_BUNDLE_MANIFEST); + String id = getManifestEntryValue(manifest, Constants.BUNDLE_SYMBOLICNAME); + if (id != null) + return id; + manifest = project.findMember(PLUGIN_MANIFEST); + if (manifest == null) + manifest = project.findMember(FRAGMENT_MANIFEST); + if (manifest instanceof IFile) { + InputStream in = null; + try { + DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + in = ((IFile) manifest).getContents(); + Document document = builder.parse(in); + Node node = getXMLElement(document, "plugin"); //$NON-NLS-1$ + if (node == null) + node = getXMLElement(document, "fragment"); //$NON-NLS-1$ + if (node != null) + node = node.getAttributes().getNamedItem("id"); //$NON-NLS-1$ + if (node != null) + return node.getNodeValue(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (in != null) + in.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return null; + } + + /** + * Returns all project containing plugin/fragment of the specified + * project. If the specified project itself is a fragment, then only this is returned. + * + * @param pluginProject the plugin project + * @return the all project containing a fragment or null if none + */ + public static IProject[] lookupFragment(IProject pluginProject) { + List<IProject> fragmentIds = new ArrayList<IProject>(); + + String pluginId = PDEUtils.getPluginId(pluginProject); + if (pluginId == null) + return null; + String fragmentId = getFragmentId(pluginProject, getPluginId(getFragmentHost(pluginProject))); + if (fragmentId != null){ + fragmentIds.add(pluginProject); + return fragmentIds.toArray(new IProject[0]); + } + + IProject[] projects = pluginProject.getWorkspace().getRoot().getProjects(); + for (int i = 0; i < projects.length; i++) { + IProject project = projects[i]; + if (!project.isOpen()) + continue; + if (getFragmentId(project, pluginId) == null) + continue; + fragmentIds.add(project); + } + + if (fragmentIds.size() > 0) return fragmentIds.toArray(new IProject[0]); + else return null; + } + + public static boolean isFragment(IProject pluginProject){ + String pluginId = PDEUtils.getPluginId(pluginProject); + if (pluginId == null) + return false; + String fragmentId = getFragmentId(pluginProject, getPluginId(getFragmentHost(pluginProject))); + if (fragmentId != null) + return true; + else + return false; + } + + public static List<IProject> getFragments(IProject hostProject){ + List<IProject> fragmentIds = new ArrayList<IProject>(); + + String pluginId = PDEUtils.getPluginId(hostProject); + IProject[] projects = hostProject.getWorkspace().getRoot().getProjects(); + + for (int i = 0; i < projects.length; i++) { + IProject project = projects[i]; + if (!project.isOpen()) + continue; + if (getFragmentId(project, pluginId) == null) + continue; + fragmentIds.add(project); + } + + return fragmentIds; + } + + /** + * Returns the fragment-id of the project if it is a fragment project with + * the specified host plugin id as host. Else null is returned. + * + * @param project the project + * @param hostPluginId the host plugin id + * @return the plugin-id or null + */ + public static String getFragmentId(IProject project, String hostPluginId) { + IResource manifest = project.findMember(FRAGMENT_MANIFEST); + Node fragmentNode = getXMLElement(getXMLDocument(manifest), "fragment"); //$NON-NLS-1$ + if (fragmentNode != null) { + Node hostNode = fragmentNode.getAttributes().getNamedItem("plugin-id"); //$NON-NLS-1$ + if (hostNode != null && hostNode.getNodeValue().equals(hostPluginId)) { + Node idNode = fragmentNode.getAttributes().getNamedItem("id"); //$NON-NLS-1$ + if (idNode != null) + return idNode.getNodeValue(); + } + } + manifest = project.findMember(OSGI_BUNDLE_MANIFEST); + String hostId = getManifestEntryValue(manifest, Constants.FRAGMENT_HOST); + if (hostId != null && hostId.equals(hostPluginId)) + return getManifestEntryValue(manifest, Constants.BUNDLE_SYMBOLICNAME); + return null; + } + + /** + * Returns the host plugin project of the specified project if it contains a fragment. + * + * @param fragment the fragment project + * @return the host plugin project or null + */ + public static IProject getFragmentHost(IProject fragment) { + IResource manifest = fragment.findMember(FRAGMENT_MANIFEST); + Node fragmentNode = getXMLElement(getXMLDocument(manifest), "fragment"); //$NON-NLS-1$ + if (fragmentNode != null) { + Node hostNode = fragmentNode.getAttributes().getNamedItem("plugin-id"); //$NON-NLS-1$ + if (hostNode != null) + return fragment.getWorkspace().getRoot().getProject(hostNode.getNodeValue()); + } + manifest = fragment.findMember(OSGI_BUNDLE_MANIFEST); + String hostId = getManifestEntryValue(manifest, Constants.FRAGMENT_HOST); + if (hostId != null) + return fragment.getWorkspace().getRoot().getProject(hostId); + return null; + } + + /** + * Returns the file content as UTF8 string. + * + * @param file + * @param charset + * @return + */ + public static String getFileContent(IFile file, String charset) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + InputStream in = null; + try { + in = file.getContents(true); + byte[] buf = new byte[8000]; + for (int count; (count = in.read(buf)) != -1;) + outputStream.write(buf, 0, count); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ignore) { + } + } + } + try { + return outputStream.toString(charset); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return outputStream.toString(); + } + } + + private static String getManifestEntryValue(IResource manifest, String entryKey) { + if (manifest instanceof IFile) { + String content = getFileContent((IFile) manifest, "UTF8"); //$NON-NLS-1$ + int index = content.indexOf(entryKey); + if (index != -1) { + StringTokenizer st = new StringTokenizer(content.substring(index + + entryKey.length()), ";:\r\n"); //$NON-NLS-1$ + return st.nextToken().trim(); + } + } + return null; + } + + private static Document getXMLDocument(IResource resource) { + if (!(resource instanceof IFile)) + return null; + InputStream in = null; + try { + DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + in = ((IFile) resource).getContents(); + return builder.parse(in); + } catch (Exception e) { + e.printStackTrace(); + return null; + } finally { + try { + if (in != null) + in.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private static Node getXMLElement(Document document, String name) { + if (document == null) + return null; + NodeList list = document.getChildNodes(); + for (int i = 0; i < list.getLength(); i++) { + Node node = list.item(i); + if (node.getNodeType() != Node.ELEMENT_NODE) + continue; + if (name.equals(node.getNodeName())) + return node; + } + return null; + } + +} diff --git a/org.eclipselabs.tapiji.translator/org.eclipselabs.tapiji.translator.product b/org.eclipselabs.tapiji.translator/org.eclipselabs.tapiji.translator.product index 6d9879fe..49e3c0f0 100644 --- a/org.eclipselabs.tapiji.translator/org.eclipselabs.tapiji.translator.product +++ b/org.eclipselabs.tapiji.translator/org.eclipselabs.tapiji.translator.product @@ -235,9 +235,11 @@ litigation. <plugin id="org.eclipse.core.expressions"/> <plugin id="org.eclipse.core.filebuffers"/> <plugin id="org.eclipse.core.filesystem"/> + <plugin id="org.eclipse.core.filesystem.win32.x86" fragment="true"/> <plugin id="org.eclipse.core.filesystem.win32.x86_64" fragment="true"/> <plugin id="org.eclipse.core.jobs"/> <plugin id="org.eclipse.core.resources"/> + <plugin id="org.eclipse.core.resources.win32.x86" fragment="true"/> <plugin id="org.eclipse.core.runtime"/> <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/> <plugin id="org.eclipse.ecf"/> @@ -256,6 +258,7 @@ litigation. <plugin id="org.eclipse.equinox.preferences"/> <plugin id="org.eclipse.equinox.registry"/> <plugin id="org.eclipse.equinox.security"/> + <plugin id="org.eclipse.equinox.security.win32.x86" fragment="true"/> <plugin id="org.eclipse.equinox.security.win32.x86_64" fragment="true"/> <plugin id="org.eclipse.help"/> <plugin id="org.eclipse.jdt.compiler.apt" fragment="true"/> @@ -267,6 +270,7 @@ litigation. <plugin id="org.eclipse.osgi"/> <plugin id="org.eclipse.osgi.services"/> <plugin id="org.eclipse.swt"/> + <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/> <plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/> <plugin id="org.eclipse.text"/> <plugin id="org.eclipse.ui"/>
42d5bdd3378bbd246a5ecf4a3c09f76f519e4e9b
elasticsearch
If matching root doc's inner objects don't match- the `nested_filter` then the `missing` value should be used to sort the root- doc. Closes -3020--
a
https://github.com/elastic/elasticsearch
diff --git a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/ByteValuesComparator.java b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/ByteValuesComparator.java index a34a2f0650102..797b680119d3c 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/ByteValuesComparator.java +++ b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/ByteValuesComparator.java @@ -66,4 +66,9 @@ public void add(int slot, int doc) { public void divide(int slot, int divisor) { values[slot] /= divisor; } + + @Override + public void missing(int slot) { + values[slot] = (byte) missingValue; + } } diff --git a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparator.java b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparator.java index cdcef1d39d8ad..a49aebca609dd 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparator.java +++ b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparator.java @@ -66,4 +66,9 @@ public void add(int slot, int doc) { public void divide(int slot, int divisor) { values[slot] /= divisor; } + + @Override + public void missing(int slot) { + values[slot] = missingValue; + } } diff --git a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorBase.java b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorBase.java index 4af80a427ec10..1f798326608ee 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorBase.java +++ b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/DoubleValuesComparatorBase.java @@ -61,6 +61,11 @@ public final FieldComparator<T> setNextReader(AtomicReaderContext context) throw return this; } + @Override + public int compareBottomMissing() { + return compare(bottom, missingValue); + } + static final int compare(double left, double right) { return Double.compare(left, right); } diff --git a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/FloatValuesComparator.java b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/FloatValuesComparator.java index 0a41d9b3f1665..84045fadd3484 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/FloatValuesComparator.java +++ b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/FloatValuesComparator.java @@ -66,4 +66,9 @@ public void add(int slot, int doc) { public void divide(int slot, int divisor) { values[slot] /= divisor; } + + @Override + public void missing(int slot) { + values[slot] = (float) missingValue; + } } diff --git a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/IntValuesComparator.java b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/IntValuesComparator.java index 02ffc9434193a..725010cf1c6e2 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/IntValuesComparator.java +++ b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/IntValuesComparator.java @@ -72,4 +72,9 @@ public void add(int slot, int doc) { public void divide(int slot, int divisor) { values[slot] /= divisor; } + + @Override + public void missing(int slot) { + values[slot] = (int) missingValue; + } } diff --git a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparator.java b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparator.java index 8d75c17039519..675fa6b3575d2 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparator.java +++ b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparator.java @@ -65,4 +65,9 @@ public void add(int slot, int doc) { public void divide(int slot, int divisor) { values[slot] /= divisor; } + + @Override + public void missing(int slot) { + values[slot] = missingValue; + } } diff --git a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorBase.java b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorBase.java index c19f3f655c5d9..f030fe9f12346 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorBase.java +++ b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorBase.java @@ -72,6 +72,11 @@ public final FieldComparator<T> setNextReader(AtomicReaderContext context) throw return this; } + @Override + public int compareBottomMissing() { + return compare(bottom, missingValue); + } + private static final class MultiValueWrapper extends LongValues.Filtered { private final SortMode sortMode; diff --git a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/NumberComparatorBase.java b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/NumberComparatorBase.java index 66693987c51fc..ae05d9722ee1d 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/NumberComparatorBase.java +++ b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/NumberComparatorBase.java @@ -42,4 +42,19 @@ public abstract class NumberComparatorBase<T> extends FieldComparator<T> { * @param divisor The specified divisor */ public abstract void divide(int slot, int divisor); + + /** + * Assigns the underlying missing value to the specified slot, if the actual implementation supports missing value. + * + * @param slot The slot to assign the the missing value to. + */ + public abstract void missing(int slot); + + /** + * Compares the missing value to the bottom. + * + * @return any N < 0 if the bottom value is not competitive with the missing value, any N > 0 if the + * bottom value is competitive with the missing value and 0 if they are equal. + */ + public abstract int compareBottomMissing(); } diff --git a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/ShortValuesComparator.java b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/ShortValuesComparator.java index 107d995a46fbf..3794a141e5041 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/ShortValuesComparator.java +++ b/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/ShortValuesComparator.java @@ -68,4 +68,9 @@ public void add(int slot, int doc) { public void divide(int slot, int divisor) { values[slot] /= divisor; } + + @Override + public void missing(int slot) { + values[slot] = (short) missingValue; + } } diff --git a/src/main/java/org/elasticsearch/index/search/nested/NestedFieldComparatorSource.java b/src/main/java/org/elasticsearch/index/search/nested/NestedFieldComparatorSource.java index fe87ecd418ea9..aebcce3234bcd 100644 --- a/src/main/java/org/elasticsearch/index/search/nested/NestedFieldComparatorSource.java +++ b/src/main/java/org/elasticsearch/index/search/nested/NestedFieldComparatorSource.java @@ -59,9 +59,9 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, int sortP case MIN: return new NestedFieldComparator.Lowest(wrappedComparator, rootDocumentsFilter, innerDocumentsFilter, numHits); case SUM: - return new Sum((NumberComparatorBase) wrappedComparator, rootDocumentsFilter, innerDocumentsFilter, numHits); + return new NestedFieldComparator.Sum((NumberComparatorBase) wrappedComparator, rootDocumentsFilter, innerDocumentsFilter, numHits); case AVG: - return new Avg((NumberComparatorBase) wrappedComparator, rootDocumentsFilter, innerDocumentsFilter, numHits); + return new NestedFieldComparator.Avg((NumberComparatorBase) wrappedComparator, rootDocumentsFilter, innerDocumentsFilter, numHits); default: throw new ElasticSearchIllegalArgumentException( String.format("Unsupported sort_mode[%s] for nested type", sortMode) @@ -73,20 +73,21 @@ public FieldComparator<?> newComparator(String fieldname, int numHits, int sortP public SortField.Type reducedType() { return wrappedSource.reducedType(); } + } -class Sum extends FieldComparator { +abstract class NestedFieldComparator extends FieldComparator { final Filter rootDocumentsFilter; final Filter innerDocumentsFilter; final int spareSlot; - NumberComparatorBase wrappedComparator; + FieldComparator wrappedComparator; FixedBitSet rootDocuments; FixedBitSet innerDocuments; int bottomSlot; - Sum(NumberComparatorBase wrappedComparator, Filter rootDocumentsFilter, Filter innerDocumentsFilter, int spareSlot) { + NestedFieldComparator(FieldComparator wrappedComparator, Filter rootDocumentsFilter, Filter innerDocumentsFilter, int spareSlot) { this.wrappedComparator = wrappedComparator; this.rootDocumentsFilter = rootDocumentsFilter; this.innerDocumentsFilter = innerDocumentsFilter; @@ -94,12 +95,12 @@ class Sum extends FieldComparator { } @Override - public int compare(int slot1, int slot2) { + public final int compare(int slot1, int slot2) { return wrappedComparator.compare(slot1, slot2); } @Override - public void setBottom(int slot) { + public final void setBottom(int slot) { wrappedComparator.setBottom(slot); this.bottomSlot = slot; } @@ -123,171 +124,19 @@ public FieldComparator setNextReader(AtomicReaderContext context) throws IOExcep this.rootDocuments = DocIdSets.toFixedBitSet(rootDocuments.iterator(), context.reader().maxDoc()); } - wrappedComparator = (NumberComparatorBase) wrappedComparator.setNextReader(context); + wrappedComparator = wrappedComparator.setNextReader(context); return this; } @Override - public Object value(int slot) { + public final Object value(int slot) { return wrappedComparator.value(slot); } @Override - public int compareBottom(int rootDoc) throws IOException { - if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { - return 0; - } - - int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); - int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); - if (nestedDoc >= rootDoc || nestedDoc == -1) { - return 0; - } - - wrappedComparator.copy(spareSlot, nestedDoc); - nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - while (nestedDoc > prevRootDoc && nestedDoc < rootDoc) { - wrappedComparator.add(spareSlot, nestedDoc); - nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - } - return compare(bottomSlot, spareSlot); - } - - @Override - public void copy(int slot, int rootDoc) throws IOException { - if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { - return; - } - - int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); - int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); - if (nestedDoc >= rootDoc || nestedDoc == -1) { - return; - } - - wrappedComparator.copy(slot, nestedDoc); - nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - while (nestedDoc > prevRootDoc && nestedDoc < rootDoc) { - wrappedComparator.add(slot, nestedDoc); - nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - } - } - - @Override - public int compareDocToValue(int rootDoc, Object value) throws IOException { + public final int compareDocToValue(int rootDoc, Object value) throws IOException { throw new UnsupportedOperationException("compareDocToValue() not used for sorting in ES"); } -} - -final class Avg extends Sum { - - Avg(NumberComparatorBase wrappedComparator, Filter rootDocumentsFilter, Filter innerDocumentsFilter, int spareSlot) { - super(wrappedComparator, rootDocumentsFilter, innerDocumentsFilter, spareSlot); - } - - @Override - public int compareBottom(int rootDoc) throws IOException { - if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { - return 0; - } - - int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); - int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); - if (nestedDoc >= rootDoc || nestedDoc == -1) { - return 0; - } - - int counter = 1; - wrappedComparator.copy(spareSlot, nestedDoc); - nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - while (nestedDoc > prevRootDoc && nestedDoc < rootDoc) { - wrappedComparator.add(spareSlot, nestedDoc); - nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - counter++; - } - wrappedComparator.divide(spareSlot, counter); - return compare(bottomSlot, spareSlot); - } - - @Override - public void copy(int slot, int rootDoc) throws IOException { - if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { - return; - } - - int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); - int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); - if (nestedDoc >= rootDoc || nestedDoc == -1) { - return; - } - - int counter = 1; - wrappedComparator.copy(slot, nestedDoc); - nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - while (nestedDoc > prevRootDoc && nestedDoc < rootDoc) { - wrappedComparator.add(slot, nestedDoc); - nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - counter++; - } - wrappedComparator.divide(slot, counter); - } -} - -// Move to Lucene join module -abstract class NestedFieldComparator extends FieldComparator { - - final Filter rootDocumentsFilter; - final Filter innerDocumentsFilter; - final int spareSlot; - - FieldComparator wrappedComparator; - FixedBitSet rootDocuments; - FixedBitSet innerDocuments; - - NestedFieldComparator(FieldComparator wrappedComparator, Filter rootDocumentsFilter, Filter innerDocumentsFilter, int spareSlot) { - this.wrappedComparator = wrappedComparator; - this.rootDocumentsFilter = rootDocumentsFilter; - this.innerDocumentsFilter = innerDocumentsFilter; - this.spareSlot = spareSlot; - } - - @Override - public int compare(int slot1, int slot2) { - return wrappedComparator.compare(slot1, slot2); - } - - @Override - public void setBottom(int slot) { - wrappedComparator.setBottom(slot); - } - - @Override - public FieldComparator setNextReader(AtomicReaderContext context) throws IOException { - DocIdSet innerDocuments = innerDocumentsFilter.getDocIdSet(context, null); - if (DocIdSets.isEmpty(innerDocuments)) { - this.innerDocuments = null; - } else if (innerDocuments instanceof FixedBitSet) { - this.innerDocuments = (FixedBitSet) innerDocuments; - } else { - this.innerDocuments = DocIdSets.toFixedBitSet(innerDocuments.iterator(), context.reader().maxDoc()); - } - DocIdSet rootDocuments = rootDocumentsFilter.getDocIdSet(context, null); - if (DocIdSets.isEmpty(rootDocuments)) { - this.rootDocuments = null; - } else if (rootDocuments instanceof FixedBitSet) { - this.rootDocuments = (FixedBitSet) rootDocuments; - } else { - this.rootDocuments = DocIdSets.toFixedBitSet(rootDocuments.iterator(), context.reader().maxDoc()); - } - - wrappedComparator = wrappedComparator.setNextReader(context); - return this; - } - - @Override - public Object value(int slot) { - return wrappedComparator.value(slot); - } final static class Lowest extends NestedFieldComparator { @@ -298,14 +147,14 @@ final static class Lowest extends NestedFieldComparator { @Override public int compareBottom(int rootDoc) throws IOException { if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { - return 0; + return compareBottomMissing(wrappedComparator); } // We need to copy the lowest value from all nested docs into slot. int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); if (nestedDoc >= rootDoc || nestedDoc == -1) { - return 0; + return compareBottomMissing(wrappedComparator); } // We only need to emit a single cmp value for any matching nested doc @@ -333,6 +182,7 @@ public int compareBottom(int rootDoc) throws IOException { @Override public void copy(int slot, int rootDoc) throws IOException { if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { + copyMissing(wrappedComparator, slot); return; } @@ -340,6 +190,7 @@ public void copy(int slot, int rootDoc) throws IOException { int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); if (nestedDoc >= rootDoc || nestedDoc == -1) { + copyMissing(wrappedComparator, slot); return; } wrappedComparator.copy(spareSlot, nestedDoc); @@ -357,42 +208,6 @@ public void copy(int slot, int rootDoc) throws IOException { } } - @Override - @SuppressWarnings("unchecked") - public int compareDocToValue(int rootDoc, Object value) throws IOException { - if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { - return 0; - } - - // We need to copy the lowest value from all nested docs into slot. - int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); - int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); - if (nestedDoc >= rootDoc || nestedDoc == -1) { - return 0; - } - - // We only need to emit a single cmp value for any matching nested doc - int cmp = wrappedComparator.compareBottom(nestedDoc); - if (cmp > 0) { - return cmp; - } - - while (true) { - nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - if (nestedDoc >= rootDoc || nestedDoc == -1) { - return cmp; - } - int cmp1 = wrappedComparator.compareDocToValue(nestedDoc, value); - if (cmp1 > 0) { - return cmp1; - } else { - if (cmp1 == 0) { - cmp = 0; - } - } - } - } - } final static class Highest extends NestedFieldComparator { @@ -404,13 +219,13 @@ final static class Highest extends NestedFieldComparator { @Override public int compareBottom(int rootDoc) throws IOException { if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { - return 0; + return compareBottomMissing(wrappedComparator); } int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); if (nestedDoc >= rootDoc || nestedDoc == -1) { - return 0; + return compareBottomMissing(wrappedComparator); } int cmp = wrappedComparator.compareBottom(nestedDoc); @@ -437,12 +252,14 @@ public int compareBottom(int rootDoc) throws IOException { @Override public void copy(int slot, int rootDoc) throws IOException { if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { + copyMissing(wrappedComparator, slot); return; } int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); if (nestedDoc >= rootDoc || nestedDoc == -1) { + copyMissing(wrappedComparator, slot); return; } wrappedComparator.copy(spareSlot, nestedDoc); @@ -460,40 +277,146 @@ public void copy(int slot, int rootDoc) throws IOException { } } + } + + final static class Sum extends NestedFieldComparator { + + NumberComparatorBase wrappedComparator; + + Sum(NumberComparatorBase wrappedComparator, Filter rootDocumentsFilter, Filter innerDocumentsFilter, int spareSlot) { + super(wrappedComparator, rootDocumentsFilter, innerDocumentsFilter, spareSlot); + this.wrappedComparator = wrappedComparator; + } + + @Override + public int compareBottom(int rootDoc) throws IOException { + if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { + return compareBottomMissing(wrappedComparator); + } + + int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); + int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); + if (nestedDoc >= rootDoc || nestedDoc == -1) { + return compareBottomMissing(wrappedComparator); + } + + wrappedComparator.copy(spareSlot, nestedDoc); + nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); + while (nestedDoc > prevRootDoc && nestedDoc < rootDoc) { + wrappedComparator.add(spareSlot, nestedDoc); + nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); + } + return compare(bottomSlot, spareSlot); + } + @Override - @SuppressWarnings("unchecked") - public int compareDocToValue(int rootDoc, Object value) throws IOException { + public void copy(int slot, int rootDoc) throws IOException { if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { - return 0; + copyMissing(wrappedComparator, slot); + return; } int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); if (nestedDoc >= rootDoc || nestedDoc == -1) { + copyMissing(wrappedComparator, slot); + return; + } + + wrappedComparator.copy(slot, nestedDoc); + nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); + while (nestedDoc > prevRootDoc && nestedDoc < rootDoc) { + wrappedComparator.add(slot, nestedDoc); + nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); + } + } + + @Override + public FieldComparator setNextReader(AtomicReaderContext context) throws IOException { + super.setNextReader(context); + wrappedComparator = (NumberComparatorBase) super.wrappedComparator; + return this; + } + + } + + final static class Avg extends NestedFieldComparator { + + NumberComparatorBase wrappedComparator; + + Avg(NumberComparatorBase wrappedComparator, Filter rootDocumentsFilter, Filter innerDocumentsFilter, int spareSlot) { + super(wrappedComparator, rootDocumentsFilter, innerDocumentsFilter, spareSlot); + this.wrappedComparator = wrappedComparator; + } + + @Override + public int compareBottom(int rootDoc) throws IOException { + if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { return 0; } - int cmp = wrappedComparator.compareBottom(nestedDoc); - if (cmp < 0) { - return cmp; + int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); + int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); + if (nestedDoc >= rootDoc || nestedDoc == -1) { + return compareBottomMissing(wrappedComparator); } - while (true) { + int counter = 1; + wrappedComparator.copy(spareSlot, nestedDoc); + nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); + while (nestedDoc > prevRootDoc && nestedDoc < rootDoc) { + wrappedComparator.add(spareSlot, nestedDoc); nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); - if (nestedDoc >= rootDoc || nestedDoc == -1) { - return cmp; - } - int cmp1 = wrappedComparator.compareDocToValue(nestedDoc, value); - if (cmp1 < 0) { - return cmp1; - } else { - if (cmp1 == 0) { - cmp = 0; - } - } + counter++; } + wrappedComparator.divide(spareSlot, counter); + return compare(bottomSlot, spareSlot); } + @Override + public void copy(int slot, int rootDoc) throws IOException { + if (rootDoc == 0 || rootDocuments == null || innerDocuments == null) { + return; + } + + int prevRootDoc = rootDocuments.prevSetBit(rootDoc - 1); + int nestedDoc = innerDocuments.nextSetBit(prevRootDoc + 1); + if (nestedDoc >= rootDoc || nestedDoc == -1) { + copyMissing(wrappedComparator, slot); + return; + } + + int counter = 1; + wrappedComparator.copy(slot, nestedDoc); + nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); + while (nestedDoc > prevRootDoc && nestedDoc < rootDoc) { + wrappedComparator.add(slot, nestedDoc); + nestedDoc = innerDocuments.nextSetBit(nestedDoc + 1); + counter++; + } + wrappedComparator.divide(slot, counter); + } + + @Override + public FieldComparator setNextReader(AtomicReaderContext context) throws IOException { + super.setNextReader(context); + wrappedComparator = (NumberComparatorBase) super.wrappedComparator; + return this; + } + } + + static final void copyMissing(FieldComparator comparator, int slot) { + if (comparator instanceof NumberComparatorBase) { + ((NumberComparatorBase) comparator).missing(slot); + } + } + + static final int compareBottomMissing(FieldComparator comparator) { + if (comparator instanceof NumberComparatorBase) { + return ((NumberComparatorBase) comparator).compareBottomMissing(); + } else { + return 0; + } } } \ No newline at end of file diff --git a/src/test/java/org/elasticsearch/test/integration/nested/SimpleNestedTests.java b/src/test/java/org/elasticsearch/test/integration/nested/SimpleNestedTests.java index 05eeeeb565779..19e6d854d7996 100644 --- a/src/test/java/org/elasticsearch/test/integration/nested/SimpleNestedTests.java +++ b/src/test/java/org/elasticsearch/test/integration/nested/SimpleNestedTests.java @@ -682,6 +682,96 @@ public void testSimpleNestedSorting() throws Exception { assertThat(searchResponse.getHits().hits()[2].sortValues()[0].toString(), equalTo("2")); } + @Test + public void testSimpleNestedSorting_withNestedFilterMissing() throws Exception { + client.admin().indices().prepareDelete().execute().actionGet(); + client.admin().indices().prepareCreate("test") + .setSettings(settingsBuilder() + .put("index.number_of_shards", 1) + .put("index.number_of_replicas", 0) + .put("index.referesh_interval", -1) + .build() + ) + .addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties") + .startObject("nested1") + .field("type", "nested") + .endObject() + .endObject().endObject().endObject()) + .execute().actionGet(); + client.admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + + client.prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject() + .field("field1", 1) + .startArray("nested1") + .startObject() + .field("field1", 5) + .field("field2", true) + .endObject() + .startObject() + .field("field1", 4) + .field("field2", true) + .endObject() + .endArray() + .endObject()).execute().actionGet(); + client.prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject() + .field("field1", 2) + .startArray("nested1") + .startObject() + .field("field1", 1) + .field("field2", true) + .endObject() + .startObject() + .field("field1", 2) + .field("field2", true) + .endObject() + .endArray() + .endObject()).execute().actionGet(); + // Doc with missing nested docs if nested filter is used + client.admin().indices().prepareRefresh().execute().actionGet(); + client.prepareIndex("test", "type1", "3").setSource(jsonBuilder().startObject() + .field("field1", 3) + .startArray("nested1") + .startObject() + .field("field1", 3) + .field("field2", false) + .endObject() + .startObject() + .field("field1", 4) + .field("field2", false) + .endObject() + .endArray() + .endObject()).execute().actionGet(); + client.admin().indices().prepareRefresh().execute().actionGet(); + + SearchResponse searchResponse = client.prepareSearch("test") + .setTypes("type1") + .setQuery(QueryBuilders.matchAllQuery()) + .addSort(SortBuilders.fieldSort("nested1.field1").setNestedFilter(termFilter("nested1.field2", true)).missing(10).order(SortOrder.ASC)) + .execute().actionGet(); + + assertThat(searchResponse.getHits().totalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().hits()[0].id(), equalTo("2")); + assertThat(searchResponse.getHits().hits()[0].sortValues()[0].toString(), equalTo("1")); + assertThat(searchResponse.getHits().hits()[1].id(), equalTo("1")); + assertThat(searchResponse.getHits().hits()[1].sortValues()[0].toString(), equalTo("4")); + assertThat(searchResponse.getHits().hits()[2].id(), equalTo("3")); + assertThat(searchResponse.getHits().hits()[2].sortValues()[0].toString(), equalTo("10")); + + searchResponse = client.prepareSearch("test") + .setTypes("type1") + .setQuery(QueryBuilders.matchAllQuery()) + .addSort(SortBuilders.fieldSort("nested1.field1").setNestedFilter(termFilter("nested1.field2", true)).missing(10).order(SortOrder.DESC)) + .execute().actionGet(); + + assertThat(searchResponse.getHits().totalHits(), equalTo(3l)); + assertThat(searchResponse.getHits().hits()[0].id(), equalTo("3")); + assertThat(searchResponse.getHits().hits()[0].sortValues()[0].toString(), equalTo("10")); + assertThat(searchResponse.getHits().hits()[1].id(), equalTo("1")); + assertThat(searchResponse.getHits().hits()[1].sortValues()[0].toString(), equalTo("5")); + assertThat(searchResponse.getHits().hits()[2].id(), equalTo("2")); + assertThat(searchResponse.getHits().hits()[2].sortValues()[0].toString(), equalTo("2")); + } + @Test public void testSortNestedWithNestedFilter() throws Exception { client.admin().indices().prepareDelete().execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/test/unit/index/search/nested/AbstractNumberNestedSortingTests.java b/src/test/java/org/elasticsearch/test/unit/index/search/nested/AbstractNumberNestedSortingTests.java index ef1027c1995b2..7f6294821e586 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/search/nested/AbstractNumberNestedSortingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/search/nested/AbstractNumberNestedSortingTests.java @@ -28,7 +28,6 @@ import org.apache.lucene.search.*; import org.apache.lucene.search.join.ScoreMode; import org.apache.lucene.search.join.ToParentBlockJoinQuery; -import org.elasticsearch.common.lucene.search.AndFilter; import org.elasticsearch.common.lucene.search.NotFilter; import org.elasticsearch.common.lucene.search.TermFilter; import org.elasticsearch.common.lucene.search.XFilteredQuery; @@ -40,7 +39,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; @@ -148,6 +146,7 @@ public void testNestedSorting() throws Exception { document.add(createField("field1", 5, Field.Store.NO)); docs.add(document); writer.addDocuments(docs); + writer.commit(); docs.clear(); document = new Document(); @@ -167,12 +166,14 @@ public void testNestedSorting() throws Exception { document.add(createField("field1", 6, Field.Store.NO)); docs.add(document); writer.addDocuments(docs); + writer.commit(); // This doc will not be included, because it doesn't have nested docs document = new Document(); document.add(new StringField("__type", "parent", Field.Store.NO)); document.add(createField("field1", 7, Field.Store.NO)); writer.addDocument(document); + writer.commit(); docs.clear(); document = new Document(); @@ -207,7 +208,7 @@ public void testNestedSorting() throws Exception { SortMode sortMode = SortMode.SUM; IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer, false)); - IndexFieldData.XFieldComparatorSource innerFieldComparator = createInnerFieldComparator("field2", sortMode); + IndexFieldData.XFieldComparatorSource innerFieldComparator = createInnerFieldComparator("field2", sortMode, null); Filter parentFilter = new TermFilter(new Term("__type", "parent")); Filter childFilter = new NotFilter(parentFilter); NestedFieldComparatorSource nestedComparatorSource = new NestedFieldComparatorSource(sortMode, innerFieldComparator, parentFilter, childFilter); @@ -243,7 +244,7 @@ public void testNestedSorting() throws Exception { assertThat(topDocs.scoreDocs[4].doc, equalTo(3)); assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).intValue(), equalTo(9)); - childFilter = new AndFilter(Arrays.asList(new NotFilter(parentFilter), new TermFilter(new Term("filter_1", "T")))); + childFilter = new TermFilter(new Term("filter_1", "T")); nestedComparatorSource = new NestedFieldComparatorSource(sortMode, innerFieldComparator, parentFilter, childFilter); query = new ToParentBlockJoinQuery( new XFilteredQuery(new MatchAllDocsQuery(), childFilter), @@ -280,6 +281,40 @@ public void testNestedSorting() throws Exception { assertThat(topDocs.scoreDocs[4].doc, equalTo(3)); assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).intValue(), equalTo(9)); + innerFieldComparator = createInnerFieldComparator("field2", sortMode, 127); + nestedComparatorSource = new NestedFieldComparatorSource(sortMode, innerFieldComparator, parentFilter, childFilter); + sort = new Sort(new SortField("field2", nestedComparatorSource, true)); + topDocs = searcher.search(new TermQuery(new Term("__type", "parent")), 5, sort); + assertThat(topDocs.totalHits, equalTo(8)); + assertThat(topDocs.scoreDocs.length, equalTo(5)); + assertThat(topDocs.scoreDocs[0].doc, equalTo(19)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(127)); + assertThat(topDocs.scoreDocs[1].doc, equalTo(24)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[1]).fields[0]).intValue(), equalTo(127)); + assertThat(topDocs.scoreDocs[2].doc, equalTo(23)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[2]).fields[0]).intValue(), equalTo(12)); + assertThat(topDocs.scoreDocs[3].doc, equalTo(3)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[3]).fields[0]).intValue(), equalTo(9)); + assertThat(topDocs.scoreDocs[4].doc, equalTo(7)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).intValue(), equalTo(8)); + + innerFieldComparator = createInnerFieldComparator("field2", sortMode, -127); + nestedComparatorSource = new NestedFieldComparatorSource(sortMode, innerFieldComparator, parentFilter, childFilter); + sort = new Sort(new SortField("field2", nestedComparatorSource)); + topDocs = searcher.search(new TermQuery(new Term("__type", "parent")), 5, sort); + assertThat(topDocs.totalHits, equalTo(8)); + assertThat(topDocs.scoreDocs.length, equalTo(5)); + assertThat(topDocs.scoreDocs[0].doc, equalTo(19)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).intValue(), equalTo(-127)); + assertThat(topDocs.scoreDocs[1].doc, equalTo(24)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[1]).fields[0]).intValue(), equalTo(-127)); + assertThat(topDocs.scoreDocs[2].doc, equalTo(15)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[2]).fields[0]).intValue(), equalTo(3)); + assertThat(topDocs.scoreDocs[3].doc, equalTo(28)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[3]).fields[0]).intValue(), equalTo(3)); + assertThat(topDocs.scoreDocs[4].doc, equalTo(11)); + assertThat(((Number) ((FieldDoc) topDocs.scoreDocs[4]).fields[0]).intValue(), equalTo(7)); + // Moved to method, because floating point based XFieldComparatorSource have different outcome for SortMode avg, // than integral number based implementations... assertAvgScoreMode(parentFilter, searcher, innerFieldComparator); @@ -309,6 +344,6 @@ protected void assertAvgScoreMode(Filter parentFilter, IndexSearcher searcher, I protected abstract IndexableField createField(String name, int value, Field.Store store); - protected abstract IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode); + protected abstract IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode, Object missingValue); } diff --git a/src/test/java/org/elasticsearch/test/unit/index/search/nested/ByteNestedSortingTests.java b/src/test/java/org/elasticsearch/test/unit/index/search/nested/ByteNestedSortingTests.java index 3b656a344a448..fc79565f88e13 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/search/nested/ByteNestedSortingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/search/nested/ByteNestedSortingTests.java @@ -38,9 +38,9 @@ protected FieldDataType getFieldDataType() { } @Override - protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode) { + protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode, Object missingValue) { ByteArrayIndexFieldData fieldData = getForField(fieldName); - return new ByteValuesComparatorSource(fieldData, null, sortMode); + return new ByteValuesComparatorSource(fieldData, missingValue, sortMode); } @Override diff --git a/src/test/java/org/elasticsearch/test/unit/index/search/nested/DoubleNestedSortingTests.java b/src/test/java/org/elasticsearch/test/unit/index/search/nested/DoubleNestedSortingTests.java index 0d4f76e550c9d..4f6565600bb76 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/search/nested/DoubleNestedSortingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/search/nested/DoubleNestedSortingTests.java @@ -49,9 +49,9 @@ protected FieldDataType getFieldDataType() { } @Override - protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode) { + protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode, Object missingValue) { DoubleArrayIndexFieldData fieldData = getForField(fieldName); - return new DoubleValuesComparatorSource(fieldData, null, sortMode); + return new DoubleValuesComparatorSource(fieldData, missingValue, sortMode); } @Override diff --git a/src/test/java/org/elasticsearch/test/unit/index/search/nested/FloatNestedSortingTests.java b/src/test/java/org/elasticsearch/test/unit/index/search/nested/FloatNestedSortingTests.java index 3199dc26f80cd..37fc9ee1b9f2f 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/search/nested/FloatNestedSortingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/search/nested/FloatNestedSortingTests.java @@ -49,9 +49,9 @@ protected FieldDataType getFieldDataType() { } @Override - protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode) { + protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode, Object missingValue) { FloatArrayIndexFieldData fieldData = getForField(fieldName); - return new FloatValuesComparatorSource(fieldData, null, sortMode); + return new FloatValuesComparatorSource(fieldData, missingValue, sortMode); } @Override diff --git a/src/test/java/org/elasticsearch/test/unit/index/search/nested/IntegerNestedSortingTests.java b/src/test/java/org/elasticsearch/test/unit/index/search/nested/IntegerNestedSortingTests.java index a5d3ba8349118..6bd9810ac6cce 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/search/nested/IntegerNestedSortingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/search/nested/IntegerNestedSortingTests.java @@ -38,9 +38,9 @@ protected FieldDataType getFieldDataType() { } @Override - protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode) { + protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode, Object missingValue) { IntArrayIndexFieldData fieldData = getForField(fieldName); - return new IntValuesComparatorSource(fieldData, null, sortMode); + return new IntValuesComparatorSource(fieldData, missingValue, sortMode); } @Override diff --git a/src/test/java/org/elasticsearch/test/unit/index/search/nested/LongNestedSortingTests.java b/src/test/java/org/elasticsearch/test/unit/index/search/nested/LongNestedSortingTests.java index a8f2ac6bc2406..96c28899f0e30 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/search/nested/LongNestedSortingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/search/nested/LongNestedSortingTests.java @@ -38,9 +38,9 @@ protected FieldDataType getFieldDataType() { } @Override - protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode) { + protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode, Object missingValue) { LongArrayIndexFieldData fieldData = getForField(fieldName); - return new LongValuesComparatorSource(fieldData, null, sortMode); + return new LongValuesComparatorSource(fieldData, missingValue, sortMode); } @Override diff --git a/src/test/java/org/elasticsearch/test/unit/index/search/nested/ShortNestedSortingTests.java b/src/test/java/org/elasticsearch/test/unit/index/search/nested/ShortNestedSortingTests.java index b3031df068196..47bfc35e3c285 100644 --- a/src/test/java/org/elasticsearch/test/unit/index/search/nested/ShortNestedSortingTests.java +++ b/src/test/java/org/elasticsearch/test/unit/index/search/nested/ShortNestedSortingTests.java @@ -38,9 +38,9 @@ protected FieldDataType getFieldDataType() { } @Override - protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode) { + protected IndexFieldData.XFieldComparatorSource createInnerFieldComparator(String fieldName, SortMode sortMode, Object missingValue) { ShortArrayIndexFieldData fieldData = getForField(fieldName); - return new ShortValuesComparatorSource(fieldData, null, sortMode); + return new ShortValuesComparatorSource(fieldData, missingValue, sortMode); } @Override
57fcd761f2997629c75aac3617c0d97e80dcea0c
elasticsearch
Fix possible exception in toCamelCase method--
c
https://github.com/elastic/elasticsearch
diff --git a/src/main/java/org/elasticsearch/common/Strings.java b/src/main/java/org/elasticsearch/common/Strings.java index 45aa62f4246be..c2bfbfd046f71 100644 --- a/src/main/java/org/elasticsearch/common/Strings.java +++ b/src/main/java/org/elasticsearch/common/Strings.java @@ -1425,7 +1425,9 @@ public static String toCamelCase(String value, StringBuilder sb) { } changed = true; } - sb.append(Character.toUpperCase(value.charAt(++i))); + if (i < value.length() - 1) { + sb.append(Character.toUpperCase(value.charAt(++i))); + } } else { if (changed) { sb.append(c); diff --git a/src/test/java/org/elasticsearch/common/StringsTests.java b/src/test/java/org/elasticsearch/common/StringsTests.java new file mode 100644 index 0000000000000..e6f75aa9a1338 --- /dev/null +++ b/src/test/java/org/elasticsearch/common/StringsTests.java @@ -0,0 +1,36 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common; + +import org.elasticsearch.test.ElasticsearchTestCase; +import org.junit.Test; + +public class StringsTests extends ElasticsearchTestCase { + + @Test + public void testToCamelCase() { + assertEquals("foo", Strings.toCamelCase("foo")); + assertEquals("fooBar", Strings.toCamelCase("fooBar")); + assertEquals("FooBar", Strings.toCamelCase("FooBar")); + assertEquals("fooBar", Strings.toCamelCase("foo_bar")); + assertEquals("fooBarFooBar", Strings.toCamelCase("foo_bar_foo_bar")); + assertEquals("fooBar", Strings.toCamelCase("foo_bar_")); + } +}
d7217260578f7fce07eed94e33ede6ea1da01284
tapiji
Adds multi-platform dependencies to rcp translator product definition file
a
https://github.com/tapiji/tapiji
diff --git a/org.eclipselabs.tapiji.translator.rcp/org.eclipselabs.tapiji.translator.rcp.product b/org.eclipselabs.tapiji.translator.rcp/org.eclipselabs.tapiji.translator.rcp.product index c68c448d..ba82c116 100644 --- a/org.eclipselabs.tapiji.translator.rcp/org.eclipselabs.tapiji.translator.rcp.product +++ b/org.eclipselabs.tapiji.translator.rcp/org.eclipselabs.tapiji.translator.rcp.product @@ -21,7 +21,7 @@ by Stefan Strobl &amp; Martin Reiterer <windowImages i16="/org.eclipselabs.tapiji.translator/icons/TapiJI_16.png" i32="/org.eclipselabs.tapiji.translator/icons/TapiJI_32.png" i48="/org.eclipselabs.tapiji.translator/icons/TapiJI_48.png" i64="/org.eclipselabs.tapiji.translator/icons/TapiJI_64.png" i128="/org.eclipselabs.tapiji.translator/icons/TapiJI_128.png"/> - <launcher> + <launcher name="translator"> <solaris/> <win useIco="false"> <bmp/> @@ -292,10 +292,14 @@ litigation. <plugin id="org.eclipse.ltk.ui.refactoring"/> <plugin id="org.eclipse.osgi"/> <plugin id="org.eclipse.osgi.services"/> - <plugin id="org.eclipse.pde.build"/> - <plugin id="org.eclipse.pde.core"/> <plugin id="org.eclipse.swt"/> - <plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true" os="linux" ws="gtk" arch="x86_64"/> + <plugin id="org.eclipse.swt.carbon.macosx" fragment="true"/> + <plugin id="org.eclipse.swt.cocoa.macosx" fragment="true"/> + <plugin id="org.eclipse.swt.cocoa.macosx.x86_64" fragment="true"/> + <plugin id="org.eclipse.swt.gtk.linux.x86" fragment="true"/> + <plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true"/> + <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/> + <plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/> <plugin id="org.eclipse.team.core"/> <plugin id="org.eclipse.team.ui"/> <plugin id="org.eclipse.text"/>
2dc8e00ddfea221e5592d0e7cfbf0cbe1c031d57
Valadoc
gir-importer: docbook: process all <doc-* tags
a
https://github.com/GNOME/vala/
diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/src/libvaladoc/documentation/gtkdoccommentparser.vala index 372b0590aa..0f4babe5c1 100644 --- a/src/libvaladoc/documentation/gtkdoccommentparser.vala +++ b/src/libvaladoc/documentation/gtkdoccommentparser.vala @@ -1,6 +1,6 @@ /* gtkcommentparser.vala * - * Copyright (C) 2011-2012 Florian Brosch + * Copyright (C) 2011-2014 Florian Brosch * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -115,59 +115,114 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { } } + private Note? _parse_note (Api.SourceComment comment) { + Comment? cmnt = parse_root_content (comment); + if (cmnt == null) { + return null; + } + + Note note = factory.create_note (); + note.content.add_all (cmnt.content); + + return note; + } + + private void add_note (ref Comment? comment, Note? note) { + if (note == null) { + return ; + } + + if (comment == null) { + comment = factory.create_comment (); + } + + if (comment.content.size == 0) { + comment.content.add (factory.create_paragraph ()); + } + + comment.content.insert (1, note); + } + + private void add_taglet (ref Comment? comment, Taglet? taglet) { + if (taglet == null) { + return ; + } + + if (comment == null) { + comment = factory.create_comment (); + } + + comment.taglets.add (taglet); + } + public Comment? parse (Api.Node element, Api.GirSourceComment gir_comment, GirMetaData gir_metadata, Importer.InternalIdRegistrar id_registrar) { this.instance_param_name = gir_comment.instance_param_name; this.current_metadata = gir_metadata; this.id_registrar = id_registrar; this.element = element; - Comment? comment = this.parse_main_content (gir_comment); - if (comment == null) { - return null; + + Comment? cmnt = parse_root_content (gir_comment); + if (cmnt != null) { + ImporterHelper.extract_short_desc (cmnt, factory); } - if (gir_comment.return_comment != null) { - Taglet? taglet = this.parse_block_taglet (gir_comment.return_comment, "return"); - if (taglet == null) { - return null; - } - comment.taglets.add (taglet); + // deprecated: + if (gir_comment.deprecated_comment != null) { + Note? note = _parse_note (gir_comment.deprecated_comment); + add_note (ref cmnt, note); } - MapIterator<string, Api.SourceComment> iter = gir_comment.parameter_iterator (); - for (bool has_next = iter.next (); has_next; has_next = iter.next ()) { - Taglets.Param? taglet = this.parse_block_taglet (iter.get_value (), "param") as Taglets.Param; - if (taglet == null) { - return null; - } - taglet.parameter_name = iter.get_key (); + // version: + if (gir_comment.version_comment != null) { + Note? note = _parse_note (gir_comment.version_comment); + add_note (ref cmnt, note); + } + + // stability: + if (gir_comment.stability_comment != null) { + Note? note = _parse_note (gir_comment.stability_comment); + add_note (ref cmnt, note); + } - if (taglet.parameter_name == gir_comment.instance_param_name) { - taglet.parameter_name = "this"; - taglet.is_c_self_param = true; - } - comment.taglets.add (taglet); + // return: + if (gir_comment.return_comment != null) { + Taglet? taglet = parse_block_taglet (gir_comment.return_comment, "return"); + add_taglet (ref cmnt, taglet); + } + + + // parameters: + MapIterator<string, Api.SourceComment> iter = gir_comment.parameter_iterator (); + for (bool has_next = iter.next (); has_next; has_next = iter.next ()) { + Taglets.Param? taglet = parse_block_taglet (iter.get_value (), "param") as Taglets.Param; + string param_name = iter.get_key (); + + taglet.is_c_self_param = (param_name == gir_comment.instance_param_name); + taglet.parameter_name = param_name; + add_taglet (ref cmnt, taglet); } + bool first = true; foreach (LinkedList<Block> note in this.footnotes) { if (first == true && note.size > 0) { Paragraph p = note.first () as Paragraph; if (p == null) { p = factory.create_paragraph (); - comment.content.add (p); + cmnt.content.add (p); } p.content.insert (0, factory.create_text ("\n")); } - comment.content.add_all (note); + cmnt.content.add_all (note); first = false; } - return comment; + return cmnt; } private Taglet? parse_block_taglet (Api.SourceComment gir_comment, string taglet_name) { @@ -192,7 +247,7 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { return taglet as Taglet; } - private Comment? parse_main_content (Api.GirSourceComment gir_comment) { + private Comment? parse_root_content (Api.SourceComment gir_comment) { this.reset (gir_comment); current = null; @@ -391,7 +446,9 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { } string id = current.attributes.get ("id"); - id_registrar.register_symbol (id, element); + if (id != null) { + id_registrar.register_symbol (id, element); + } next (); if (!check_xml_close_tag ("anchor")) { @@ -844,7 +901,9 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { } string id = current.attributes.get ("id"); - id_registrar.register_symbol (id, element); + if (id != null) { + id_registrar.register_symbol (id, element); + } next (); parse_docbook_spaces (); @@ -1117,7 +1176,9 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { } string id = current.attributes.get ("id"); - id_registrar.register_symbol (id, element); + if (id != null) { + id_registrar.register_symbol (id, element); + } next (); LinkedList<Block> content = parse_mixed_content ();
ec0e8cf1fb4f2b99d8677666df38234a621158d2
camel
Fixed test--git-svn-id: https://svn.apache.org/repos/asf/camel/trunk@962779 13f79535-47bb-0310-9956-ffa450edef68-
c
https://github.com/apache/camel
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java b/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java index d894f019a8a0d..511a8ad2eb90c 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteAllTasksTest.java @@ -45,19 +45,18 @@ public void testShutdownCompleteAllTasks() throws Exception { // give it 20 seconds to shutdown context.getShutdownStrategy().setTimeout(20); - // start route which will pickup the 5 files - context.startRoute("route1"); - MockEndpoint bar = getMockEndpoint("mock:bar"); bar.expectedMinimumMessageCount(1); assertMockEndpointsSatisfied(); + int batch = bar.getReceivedExchanges().get(0).getProperty(Exchange.BATCH_SIZE, int.class); + // shutdown during processing context.stop(); // should route all 5 - assertEquals("Should complete all messages", 5, bar.getReceivedCounter()); + assertEquals("Should complete all messages", batch, bar.getReceivedCounter()); } @Override @@ -66,7 +65,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { @Override // START SNIPPET: e1 public void configure() throws Exception { - from(url).routeId("route1").noAutoStartup() + from(url) // let it complete all tasks during shutdown .shutdownRunningTask(ShutdownRunningTask.CompleteAllTasks) .delay(1000).to("seda:foo"); diff --git a/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteCurrentTaskOnlyTest.java b/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteCurrentTaskOnlyTest.java index a06b8ada3ec05..880d61e4efa2c 100644 --- a/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteCurrentTaskOnlyTest.java +++ b/camel-core/src/test/java/org/apache/camel/processor/ShutdownCompleteCurrentTaskOnlyTest.java @@ -45,9 +45,6 @@ public void testShutdownCompleteCurrentTaskOnly() throws Exception { // give it 20 seconds to shutdown context.getShutdownStrategy().setTimeout(20); - // start route which will pickup the 5 files - context.startRoute("route1"); - MockEndpoint bar = getMockEndpoint("mock:bar"); bar.expectedMinimumMessageCount(1); @@ -65,7 +62,7 @@ protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { - from(url).routeId("route1").noAutoStartup() + from(url) // let it complete only current task so we shutdown faster .shutdownRunningTask(ShutdownRunningTask.CompleteCurrentTaskOnly) .delay(1000).to("seda:foo");
f6083cd7e87c3bcd4a97d872c4f5ed0a95055067
Vala
geocode-glib-1.0: update to 3.12.0-5-g7eb1490
a
https://github.com/GNOME/vala/
diff --git a/vapi/geocode-glib-1.0.vapi b/vapi/geocode-glib-1.0.vapi index 8cb83b6b7a..cba4d1bfea 100644 --- a/vapi/geocode-glib-1.0.vapi +++ b/vapi/geocode-glib-1.0.vapi @@ -185,7 +185,11 @@ namespace Geocode { ESTATE, HISTORICAL_TOWN, OCEAN, - SEA + SEA, + SCHOOL, + PLACE_OF_WORSHIP, + RESTAURANT, + BAR } [CCode (cheader_filename = "geocode-glib/geocode-glib.h", cprefix = "GEOCODE_ERROR_")] public errordomain Error {
c5b22e0f974d267b11ba5b3d0b9a1f1ce73fc465
intellij-community
Improved align behavior to align only- subsequent assignments or hashes--
p
https://github.com/JetBrains/intellij-community
diff --git a/platform/lang-impl/src/com/intellij/formatting/alignment/AlignmentStrategy.java b/platform/lang-impl/src/com/intellij/formatting/alignment/AlignmentStrategy.java index 10186d5c11c12..7d18afe45ff8b 100644 --- a/platform/lang-impl/src/com/intellij/formatting/alignment/AlignmentStrategy.java +++ b/platform/lang-impl/src/com/intellij/formatting/alignment/AlignmentStrategy.java @@ -71,7 +71,7 @@ public static AlignmentStrategy wrap(Alignment alignment, IElementType ... types * of <code>'int finish = 1'</code> statement) * @return alignment retrieval strategy that follows the rules described above */ - public static AlignmentStrategy createAlignmentPerTypeStrategy(Collection<IElementType> targetTypes, boolean allowBackwardShift) { + public static AlignmentPerTypeStrategy createAlignmentPerTypeStrategy(Collection<IElementType> targetTypes, boolean allowBackwardShift) { return new AlignmentPerTypeStrategy(targetTypes, allowBackwardShift); } @@ -102,13 +102,15 @@ public Alignment getAlignment(IElementType elementType) { * Alignment strategy that creates and caches alignments for target element types and returns them for elements with the * same types. */ - private static class AlignmentPerTypeStrategy extends AlignmentStrategy { + public static class AlignmentPerTypeStrategy extends AlignmentStrategy { private final Map<IElementType, Alignment> myAlignments = new HashMap<IElementType, Alignment>(); + private final boolean myAllowBackwardShift; AlignmentPerTypeStrategy(Collection<IElementType> targetElementTypes, boolean allowBackwardShift) { + myAllowBackwardShift = allowBackwardShift; for (IElementType elementType : targetElementTypes) { - myAlignments.put(elementType, Alignment.createAlignment(allowBackwardShift)); + myAlignments.put(elementType, Alignment.createAlignment(myAllowBackwardShift)); } } @@ -116,5 +118,9 @@ private static class AlignmentPerTypeStrategy extends AlignmentStrategy { public Alignment getAlignment(IElementType elementType) { return myAlignments.get(elementType); } + + public void renewAlignment(IElementType elementType) { + myAlignments.put(elementType, Alignment.createAlignment(myAllowBackwardShift)); + } } } \ No newline at end of file
c9c816ed3fb54e7ecf12c2a4bc06014b4fe277b5
ReactiveX-RxJava
Refactor test to use CountDownLatch instead of- Thread.sleep--
p
https://github.com/ReactiveX/RxJava
diff --git a/rxjava-core/src/main/java/rx/operators/OperationObserveOn.java b/rxjava-core/src/main/java/rx/operators/OperationObserveOn.java index 4f94cda6d5..4a09797f85 100644 --- a/rxjava-core/src/main/java/rx/operators/OperationObserveOn.java +++ b/rxjava-core/src/main/java/rx/operators/OperationObserveOn.java @@ -15,12 +15,17 @@ */ package rx.operators; -import static org.mockito.Matchers.*; +import static org.junit.Assert.*; import static org.mockito.Mockito.*; -import org.junit.Test; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import org.junit.Test; import org.mockito.InOrder; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + import rx.Observable; import rx.Observer; import rx.Scheduler; @@ -66,7 +71,6 @@ public void testObserveOn() { verify(observer, times(1)).onCompleted(); } - @Test @SuppressWarnings("unchecked") public void testOrdering() throws InterruptedException { @@ -76,9 +80,21 @@ public void testOrdering() throws InterruptedException { InOrder inOrder = inOrder(observer); + final CountDownLatch completedLatch = new CountDownLatch(1); + doAnswer(new Answer<Void>() { + + @Override + public Void answer(InvocationOnMock invocation) throws Throwable { + completedLatch.countDown(); + return null; + } + }).when(observer).onCompleted(); + obs.observeOn(Schedulers.threadPoolForComputation()).subscribe(observer); - Thread.sleep(500); // !!! not a true unit test + if (!completedLatch.await(1000, TimeUnit.MILLISECONDS)) { + fail("timed out waiting"); + } inOrder.verify(observer, times(1)).onNext("one"); inOrder.verify(observer, times(1)).onNext(null);
175d222bfc03ad84023cefb40e48b27356148ec5
hadoop
YARN-2830. Add backwords compatible- ContainerId.newInstance constructor. Contributed by Jonathan Eagles.--(cherry picked from commit 43cd07b408c6613d2c9aa89203cfa3110d830538)-
a
https://github.com/apache/hadoop
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/local/LocalContainerAllocator.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/local/LocalContainerAllocator.java index 19efe171356e9..74dfb39af4966 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/local/LocalContainerAllocator.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/local/LocalContainerAllocator.java @@ -140,7 +140,7 @@ public void handle(ContainerAllocatorEvent event) { LOG.info("Processing the event " + event.toString()); // Assign the same container ID as the AM ContainerId cID = - ContainerId.newInstance(getContext().getApplicationAttemptId(), + ContainerId.newContainerId(getContext().getApplicationAttemptId(), this.containerId.getContainerId()); Container container = recordFactory.newRecordInstance(Container.class); container.setId(cID); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java index 1edadb9742e07..de35d840b9473 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/jobhistory/TestJobHistoryEventHandler.java @@ -716,7 +716,7 @@ private class TestParams { ApplicationId appId = ApplicationId.newInstance(200, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); TaskID taskID = TaskID.forName("task_200707121733_0003_m_000005"); TaskAttemptID taskAttemptID = new TaskAttemptID(taskID, 0); JobId jobId = MRBuilderUtils.newJobId(appId, 1); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MRApp.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MRApp.java index 9885582d88a0d..3100d12ce1499 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MRApp.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MRApp.java @@ -179,7 +179,7 @@ private static ContainerId getContainerId(ApplicationId applicationId, ApplicationAttemptId appAttemptId = getApplicationAttemptId(applicationId, startCount); ContainerId containerId = - ContainerId.newInstance(appAttemptId, startCount); + ContainerId.newContainerId(appAttemptId, startCount); return containerId; } @@ -565,7 +565,7 @@ protected class MRAppContainerAllocator @Override public void handle(ContainerAllocatorEvent event) { ContainerId cId = - ContainerId.newInstance(getContext().getApplicationAttemptId(), + ContainerId.newContainerId(getContext().getApplicationAttemptId(), containerCount++); NodeId nodeId = NodeId.newInstance(NM_HOST, NM_PORT); Resource resource = Resource.newInstance(1234, 2); @@ -773,7 +773,7 @@ public static ContainerId newContainerId(int appId, int appAttemptId, ApplicationId applicationId = ApplicationId.newInstance(timestamp, appId); ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, appAttemptId); - return ContainerId.newInstance(applicationAttemptId, containerId); + return ContainerId.newContainerId(applicationAttemptId, containerId); } public static ContainerTokenIdentifier newContainerTokenIdentifier( diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MRAppBenchmark.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MRAppBenchmark.java index 160303289568e..744ca103affba 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MRAppBenchmark.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MRAppBenchmark.java @@ -140,7 +140,7 @@ public void run() { if (concurrentRunningTasks < maxConcurrentRunningTasks) { event = eventQueue.take(); ContainerId cId = - ContainerId.newInstance(getContext() + ContainerId.newContainerId(getContext() .getApplicationAttemptId(), containerCount++); //System.out.println("Allocating " + containerCount); @@ -233,7 +233,7 @@ public AllocateResponse allocate(AllocateRequest request) int numContainers = req.getNumContainers(); for (int i = 0; i < numContainers; i++) { ContainerId containerId = - ContainerId.newInstance( + ContainerId.newContainerId( getContext().getApplicationAttemptId(), request.getResponseId() + i); containers.add(Container.newInstance(containerId, diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MockJobs.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MockJobs.java index 19ac0db98dbb8..fd9c094901ae4 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MockJobs.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/MockJobs.java @@ -183,7 +183,7 @@ public static TaskReport newTaskReport(TaskId id) { public static TaskAttemptReport newTaskAttemptReport(TaskAttemptId id) { ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance( id.getTaskId().getJobId().getAppId(), 0); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 0); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 0); TaskAttemptReport report = Records.newRecord(TaskAttemptReport.class); report.setTaskAttemptId(id); report @@ -315,7 +315,7 @@ public ContainerId getAssignedContainerID() { ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(taid.getTaskId().getJobId() .getAppId(), 0); - ContainerId id = ContainerId.newInstance(appAttemptId, 0); + ContainerId id = ContainerId.newContainerId(appAttemptId, 0); return id; } @@ -640,7 +640,7 @@ public void setQueueName(String queueName) { private static AMInfo createAMInfo(int attempt) { ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(100, 1), attempt); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); return MRBuilderUtils.newAMInfo(appAttemptId, System.currentTimeMillis(), containerId, NM_HOST, NM_PORT, NM_HTTP_PORT); } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestMRAppMaster.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestMRAppMaster.java index d356eca623d2e..70437c1ba36cf 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestMRAppMaster.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestMRAppMaster.java @@ -382,7 +382,7 @@ public void testMRAppMasterCredentials() throws Exception { ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(appId, 1); ContainerId containerId = - ContainerId.newInstance(applicationAttemptId, 546); + ContainerId.newContainerId(applicationAttemptId, 546); String userName = UserGroupInformation.getCurrentUser().getShortUserName(); // Create staging dir, so MRAppMaster doesn't barf. diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestStagingCleanup.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestStagingCleanup.java index 1037e7c2ba3dd..fc64996a8e676 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestStagingCleanup.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/TestStagingCleanup.java @@ -253,7 +253,7 @@ private class TestMRApp extends MRAppMaster { public TestMRApp(ApplicationAttemptId applicationAttemptId, ContainerAllocator allocator) { - super(applicationAttemptId, ContainerId.newInstance( + super(applicationAttemptId, ContainerId.newContainerId( applicationAttemptId, 1), "testhost", 2222, 3333, System.currentTimeMillis()); this.allocator = allocator; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TestTaskAttempt.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TestTaskAttempt.java index 13303449c879e..1807c1c3e099f 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TestTaskAttempt.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/job/impl/TestTaskAttempt.java @@ -359,7 +359,7 @@ public void testLaunchFailedWhileKilling() throws Exception { new SystemClock(), null); NodeId nid = NodeId.newInstance("127.0.0.1", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -415,7 +415,7 @@ public void testContainerCleanedWhileRunning() throws Exception { new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.2", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -472,7 +472,7 @@ public void testContainerCleanedWhileCommitting() throws Exception { new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.1", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -532,7 +532,7 @@ public void testDoubleTooManyFetchFailure() throws Exception { new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.1", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -599,7 +599,7 @@ public void testAppDiognosticEventOnUnassignedTask() throws Exception { new Token(), new Credentials(), new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.1", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -649,7 +649,7 @@ public void testTooManyFetchFailureAfterKill() throws Exception { new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.1", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -714,7 +714,7 @@ public void testAppDiognosticEventOnNewTask() throws Exception { new Token(), new Credentials(), new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.1", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -760,7 +760,7 @@ public void testFetchFailureAttemptFinishTime() throws Exception{ new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.1", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -830,7 +830,7 @@ public void testContainerKillAfterAssigned() throws Exception { new Credentials(), new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.2", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -884,7 +884,7 @@ public void testContainerKillWhileRunning() throws Exception { new Credentials(), new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.2", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); @@ -941,7 +941,7 @@ public void testContainerKillWhileCommitPending() throws Exception { new Credentials(), new SystemClock(), appCtx); NodeId nid = NodeId.newInstance("127.0.0.2", 0); - ContainerId contId = ContainerId.newInstance(appAttemptId, 3); + ContainerId contId = ContainerId.newContainerId(appAttemptId, 3); Container container = mock(Container.class); when(container.getId()).thenReturn(contId); when(container.getNodeId()).thenReturn(nid); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncher.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncher.java index f2c1841e1b0a2..dc1d72f89f0f7 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncher.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncher.java @@ -115,7 +115,7 @@ public void testPoolSize() throws InterruptedException { containerLauncher.expectedCorePoolSize = ContainerLauncherImpl.INITIAL_POOL_SIZE; for (int i = 0; i < 10; i++) { - ContainerId containerId = ContainerId.newInstance(appAttemptId, i); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, i); TaskAttemptId taskAttemptId = MRBuilderUtils.newTaskAttemptId(taskId, i); containerLauncher.handle(new ContainerLauncherEvent(taskAttemptId, containerId, "host" + i + ":1234", null, @@ -137,7 +137,7 @@ public void testPoolSize() throws InterruptedException { Assert.assertEquals(10, containerLauncher.numEventsProcessed.get()); containerLauncher.finishEventHandling = false; for (int i = 0; i < 10; i++) { - ContainerId containerId = ContainerId.newInstance(appAttemptId, + ContainerId containerId = ContainerId.newContainerId(appAttemptId, i + 10); TaskAttemptId taskAttemptId = MRBuilderUtils.newTaskAttemptId(taskId, i + 10); @@ -154,7 +154,7 @@ public void testPoolSize() throws InterruptedException { // Core pool size should be 21 but the live pool size should be only 11. containerLauncher.expectedCorePoolSize = 11 + ContainerLauncherImpl.INITIAL_POOL_SIZE; containerLauncher.finishEventHandling = false; - ContainerId containerId = ContainerId.newInstance(appAttemptId, 21); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 21); TaskAttemptId taskAttemptId = MRBuilderUtils.newTaskAttemptId(taskId, 21); containerLauncher.handle(new ContainerLauncherEvent(taskAttemptId, containerId, "host11:1234", null, @@ -174,7 +174,7 @@ public void testPoolLimits() throws InterruptedException { JobId jobId = MRBuilderUtils.newJobId(appId, 8); TaskId taskId = MRBuilderUtils.newTaskId(jobId, 9, TaskType.MAP); TaskAttemptId taskAttemptId = MRBuilderUtils.newTaskAttemptId(taskId, 0); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 10); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 10); AppContext context = mock(AppContext.class); CustomContainerLauncher containerLauncher = new CustomContainerLauncher( diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java index 74e532a2b4d46..184f1b244d549 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/launcher/TestContainerLauncherImpl.java @@ -139,7 +139,7 @@ public void waitForPoolToIdle() throws InterruptedException { public static ContainerId makeContainerId(long ts, int appId, int attemptId, int id) { - return ContainerId.newInstance( + return ContainerId.newContainerId( ApplicationAttemptId.newInstance( ApplicationId.newInstance(ts, appId), attemptId), id); } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java index b8e13ff96bd57..3a7343c07b2d9 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/test/java/org/apache/hadoop/mapreduce/v2/app/rm/TestRMContainerAllocator.java @@ -688,7 +688,7 @@ public void testReportedAppProgress() throws Exception { rm.sendAMLaunched(appAttemptId); rmDispatcher.await(); - MRApp mrApp = new MRApp(appAttemptId, ContainerId.newInstance( + MRApp mrApp = new MRApp(appAttemptId, ContainerId.newContainerId( appAttemptId, 0), 10, 10, false, this.getClass().getName(), true, 1) { @Override protected Dispatcher createDispatcher() { @@ -840,7 +840,7 @@ public void testReportedAppProgressWithOnlyMaps() throws Exception { rm.sendAMLaunched(appAttemptId); rmDispatcher.await(); - MRApp mrApp = new MRApp(appAttemptId, ContainerId.newInstance( + MRApp mrApp = new MRApp(appAttemptId, ContainerId.newContainerId( appAttemptId, 0), 10, 0, false, this.getClass().getName(), true, 1) { @Override protected Dispatcher createDispatcher() { @@ -2021,7 +2021,7 @@ public void testCompletedContainerEvent() { ApplicationId applicationId = ApplicationId.newInstance(1, 1); ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance( applicationId, 1); - ContainerId containerId = ContainerId.newInstance(applicationAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(applicationAttemptId, 1); ContainerStatus status = ContainerStatus.newInstance( containerId, ContainerState.RUNNING, "", 0); @@ -2038,7 +2038,7 @@ public void testCompletedContainerEvent() { abortedStatus, attemptId); Assert.assertEquals(TaskAttemptEventType.TA_KILL, abortedEvent.getType()); - ContainerId containerId2 = ContainerId.newInstance(applicationAttemptId, 2); + ContainerId containerId2 = ContainerId.newContainerId(applicationAttemptId, 2); ContainerStatus status2 = ContainerStatus.newInstance(containerId2, ContainerState.RUNNING, "", 0); @@ -2077,7 +2077,7 @@ public void testUnregistrationOnlyIfRegistered() throws Exception { rmDispatcher.await(); MRApp mrApp = - new MRApp(appAttemptId, ContainerId.newInstance(appAttemptId, 0), 10, + new MRApp(appAttemptId, ContainerId.newContainerId(appAttemptId, 0), 10, 0, false, this.getClass().getName(), true, 1) { @Override protected Dispatcher createDispatcher() { diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestBlocks.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestBlocks.java index 82d578aa12a79..723136769e61f 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestBlocks.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestBlocks.java @@ -133,7 +133,7 @@ public void testAttemptsBlock() { ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 5); ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.newInstance(appId, 1); - ContainerId containerId = ContainerIdPBImpl.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1); when(attempt.getAssignedContainerID()).thenReturn(containerId); when(attempt.getAssignedContainerMgrAddress()).thenReturn( diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobsWithHistoryService.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobsWithHistoryService.java index 9fba91dbb1ac2..f9236a926ae83 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobsWithHistoryService.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/test/java/org/apache/hadoop/mapreduce/v2/TestMRJobsWithHistoryService.java @@ -169,7 +169,7 @@ private void verifyJobReport(JobReport jobReport, JobId jobId) { Assert.assertEquals(1, amInfos.size()); AMInfo amInfo = amInfos.get(0); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(jobId.getAppId(), 1); - ContainerId amContainerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId amContainerId = ContainerId.newContainerId(appAttemptId, 1); Assert.assertEquals(appAttemptId, amInfo.getAppAttemptId()); Assert.assertEquals(amContainerId, amInfo.getContainerId()); Assert.assertTrue(jobReport.getSubmitTime() > 0); diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 2245a79531bba..78d501096b2ff 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -895,6 +895,9 @@ Release 2.6.0 - UNRELEASED YARN-2607. Fixed issues in TestDistributedShell. (Wangda Tan via vinodkv) + YARN-2830. Add backwords compatible ContainerId.newInstance constructor. + (jeagles via acmurthy) + Release 2.5.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java index 5499a19646e73..5d0d65a966a4d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java @@ -42,7 +42,7 @@ public abstract class ContainerId implements Comparable<ContainerId>{ @Private @Unstable - public static ContainerId newInstance(ApplicationAttemptId appAttemptId, + public static ContainerId newContainerId(ApplicationAttemptId appAttemptId, long containerId) { ContainerId id = Records.newRecord(ContainerId.class); id.setContainerId(containerId); @@ -51,6 +51,18 @@ public static ContainerId newInstance(ApplicationAttemptId appAttemptId, return id; } + @Private + @Deprecated + @Unstable + public static ContainerId newInstance(ApplicationAttemptId appAttemptId, + int containerId) { + ContainerId id = Records.newRecord(ContainerId.class); + id.setContainerId(containerId); + id.setApplicationAttemptId(appAttemptId); + id.build(); + return id; + } + /** * Get the <code>ApplicationAttemptId</code> of the application to which the * <code>Container</code> was assigned. @@ -214,7 +226,7 @@ public static ContainerId fromString(String containerIdStr) { } long id = Long.parseLong(it.next()); long cid = (epoch << 40) | id; - ContainerId containerId = ContainerId.newInstance(appAttemptID, cid); + ContainerId containerId = ContainerId.newContainerId(appAttemptID, cid); return containerId; } catch (NumberFormatException n) { throw new IllegalArgumentException("Invalid ContainerId: " diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/main/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/UnmanagedAMLauncher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/main/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/UnmanagedAMLauncher.java index 2414a6777f736..d41434e94dcae 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/main/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/UnmanagedAMLauncher.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-unmanaged-am-launcher/src/main/java/org/apache/hadoop/yarn/applications/unmanagedamlauncher/UnmanagedAMLauncher.java @@ -214,7 +214,7 @@ public void launchAM(ApplicationAttemptId attemptId) if(!setClasspath && classpath!=null) { envAMList.add("CLASSPATH="+classpath); } - ContainerId containerId = ContainerId.newInstance(attemptId, 0); + ContainerId containerId = ContainerId.newContainerId(attemptId, 0); String hostname = InetAddress.getLocalHost().getHostName(); envAMList.add(Environment.CONTAINER_ID.name() + "=" + containerId); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java index ec00d45a2f13d..da7d50529ac9f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/ProtocolHATestBase.java @@ -667,7 +667,7 @@ public ApplicationAttemptId createFakeApplicationAttemptId() { } public ContainerId createFakeContainerId() { - return ContainerId.newInstance(createFakeApplicationAttemptId(), 0); + return ContainerId.newContainerId(createFakeApplicationAttemptId(), 0); } public YarnClusterMetrics createFakeYarnClusterMetrics() { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/async/impl/TestAMRMClientAsync.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/async/impl/TestAMRMClientAsync.java index b00598a5d2ec9..74d4aa47cbcde 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/async/impl/TestAMRMClientAsync.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/async/impl/TestAMRMClientAsync.java @@ -402,7 +402,7 @@ public static ContainerId newContainerId(int appId, int appAttemptId, ApplicationId applicationId = ApplicationId.newInstance(timestamp, appId); ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, appAttemptId); - return ContainerId.newInstance(applicationAttemptId, containerId); + return ContainerId.newContainerId(applicationAttemptId, containerId); } private class TestCallbackHandler implements AMRMClientAsync.CallbackHandler { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/async/impl/TestNMClientAsync.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/async/impl/TestNMClientAsync.java index 0e059d7540d5e..6f9d41d8d5090 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/async/impl/TestNMClientAsync.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/async/impl/TestNMClientAsync.java @@ -547,7 +547,7 @@ private Container mockContainer(int i) { ApplicationId.newInstance(System.currentTimeMillis(), 1); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(attemptId, i); + ContainerId containerId = ContainerId.newContainerId(attemptId, i); nodeId = NodeId.newInstance("localhost", 0); // Create an empty record containerToken = recordFactory.newRecordInstance(Token.class); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAHSClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAHSClient.java index d3c182b9cf423..a88189e5c0d84 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAHSClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAHSClient.java @@ -157,9 +157,9 @@ public void testGetContainers() throws YarnException, IOException { List<ContainerReport> reports = client.getContainers(appAttemptId); Assert.assertNotNull(reports); Assert.assertEquals(reports.get(0).getContainerId(), - (ContainerId.newInstance(appAttemptId, 1))); + (ContainerId.newContainerId(appAttemptId, 1))); Assert.assertEquals(reports.get(1).getContainerId(), - (ContainerId.newInstance(appAttemptId, 2))); + (ContainerId.newContainerId(appAttemptId, 2))); client.stop(); } @@ -176,11 +176,11 @@ public void testGetContainerReport() throws YarnException, IOException { ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(applicationId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); ContainerReport report = client.getContainerReport(containerId); Assert.assertNotNull(report); Assert.assertEquals(report.getContainerId().toString(), (ContainerId - .newInstance(expectedReports.get(0).getCurrentApplicationAttemptId(), 1)) + .newContainerId(expectedReports.get(0).getCurrentApplicationAttemptId(), 1)) .toString()); client.stop(); } @@ -349,7 +349,7 @@ private void createAppReports() { "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, - ContainerId.newInstance( + ContainerId.newContainerId( newApplicationReport.getCurrentApplicationAttemptId(), 1)); appAttempts.add(attempt); ApplicationAttemptReport attempt1 = @@ -361,7 +361,7 @@ private void createAppReports() { "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, - ContainerId.newInstance( + ContainerId.newContainerId( newApplicationReport.getCurrentApplicationAttemptId(), 2)); appAttempts.add(attempt1); attempts.put(applicationId, appAttempts); @@ -369,14 +369,14 @@ private void createAppReports() { List<ContainerReport> containerReports = new ArrayList<ContainerReport>(); ContainerReport container = ContainerReport.newInstance( - ContainerId.newInstance(attempt.getApplicationAttemptId(), 1), + ContainerId.newContainerId(attempt.getApplicationAttemptId(), 1), null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234, 5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE); containerReports.add(container); ContainerReport container1 = ContainerReport.newInstance( - ContainerId.newInstance(attempt.getApplicationAttemptId(), 2), + ContainerId.newContainerId(attempt.getApplicationAttemptId(), 2), null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234, 5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE); containerReports.add(container1); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClientOnRMRestart.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClientOnRMRestart.java index ce3086f57020c..108ad377c6b02 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClientOnRMRestart.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestAMRMClientOnRMRestart.java @@ -352,7 +352,7 @@ public void testAMRMClientForUnregisterAMOnRMRestart() throws Exception { // new NM to represent NM re-register nm1 = new MockNM("h1:1234", 10240, rm2.getResourceTrackerService()); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); NMContainerStatus containerReport = NMContainerStatus.newInstance(containerId, ContainerState.RUNNING, Resource.newInstance(1024, 1), "recover container", 0, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java index ca7c50a1270af..02f2882155541 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java @@ -348,9 +348,9 @@ public void testGetContainers() throws YarnException, IOException { List<ContainerReport> reports = client.getContainers(appAttemptId); Assert.assertNotNull(reports); Assert.assertEquals(reports.get(0).getContainerId(), - (ContainerId.newInstance(appAttemptId, 1))); + (ContainerId.newContainerId(appAttemptId, 1))); Assert.assertEquals(reports.get(1).getContainerId(), - (ContainerId.newInstance(appAttemptId, 2))); + (ContainerId.newContainerId(appAttemptId, 2))); client.stop(); } @@ -367,11 +367,11 @@ public void testGetContainerReport() throws YarnException, IOException { ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance( applicationId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); ContainerReport report = client.getContainerReport(containerId); Assert.assertNotNull(report); Assert.assertEquals(report.getContainerId().toString(), - (ContainerId.newInstance(expectedReports.get(0) + (ContainerId.newContainerId(expectedReports.get(0) .getCurrentApplicationAttemptId(), 1)).toString()); client.stop(); } @@ -481,7 +481,7 @@ private List<ApplicationReport> createAppReports() { "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, - ContainerId.newInstance( + ContainerId.newContainerId( newApplicationReport.getCurrentApplicationAttemptId(), 1)); appAttempts.add(attempt); ApplicationAttemptReport attempt1 = ApplicationAttemptReport.newInstance( @@ -492,20 +492,20 @@ private List<ApplicationReport> createAppReports() { "oUrl", "diagnostics", YarnApplicationAttemptState.FINISHED, - ContainerId.newInstance( + ContainerId.newContainerId( newApplicationReport.getCurrentApplicationAttemptId(), 2)); appAttempts.add(attempt1); attempts.put(applicationId, appAttempts); List<ContainerReport> containerReports = new ArrayList<ContainerReport>(); ContainerReport container = ContainerReport.newInstance( - ContainerId.newInstance(attempt.getApplicationAttemptId(), 1), null, + ContainerId.newContainerId(attempt.getApplicationAttemptId(), 1), null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234, 5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE); containerReports.add(container); ContainerReport container1 = ContainerReport.newInstance( - ContainerId.newInstance(attempt.getApplicationAttemptId(), 2), null, + ContainerId.newContainerId(attempt.getApplicationAttemptId(), 2), null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234, 5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE); containerReports.add(container1); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java index 5ed839847f06b..ef9439d1a77bc 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestLogsCLI.java @@ -172,9 +172,9 @@ public void testFetchApplictionLogs() throws Exception { ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.newInstance(appId, 1); - ContainerId containerId0 = ContainerIdPBImpl.newInstance(appAttemptId, 0); - ContainerId containerId1 = ContainerIdPBImpl.newInstance(appAttemptId, 1); - ContainerId containerId2 = ContainerIdPBImpl.newInstance(appAttemptId, 2); + ContainerId containerId0 = ContainerIdPBImpl.newContainerId(appAttemptId, 0); + ContainerId containerId1 = ContainerIdPBImpl.newContainerId(appAttemptId, 1); + ContainerId containerId2 = ContainerIdPBImpl.newContainerId(appAttemptId, 2); NodeId nodeId = NodeId.newInstance("localhost", 1234); // create local logs diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java index d87277a7a7ad9..9d9a86a310000 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java @@ -146,7 +146,7 @@ public void testGetApplicationAttemptReport() throws Exception { applicationId, 1); ApplicationAttemptReport attemptReport = ApplicationAttemptReport .newInstance(attemptId, "host", 124, "url", "oUrl", "diagnostics", - YarnApplicationAttemptState.FINISHED, ContainerId.newInstance( + YarnApplicationAttemptState.FINISHED, ContainerId.newContainerId( attemptId, 1)); when( client @@ -182,11 +182,11 @@ public void testGetApplicationAttempts() throws Exception { applicationId, 2); ApplicationAttemptReport attemptReport = ApplicationAttemptReport .newInstance(attemptId, "host", 124, "url", "oUrl", "diagnostics", - YarnApplicationAttemptState.FINISHED, ContainerId.newInstance( + YarnApplicationAttemptState.FINISHED, ContainerId.newContainerId( attemptId, 1)); ApplicationAttemptReport attemptReport1 = ApplicationAttemptReport .newInstance(attemptId1, "host", 124, "url", "oUrl", "diagnostics", - YarnApplicationAttemptState.FINISHED, ContainerId.newInstance( + YarnApplicationAttemptState.FINISHED, ContainerId.newContainerId( attemptId1, 1)); List<ApplicationAttemptReport> reports = new ArrayList<ApplicationAttemptReport>(); reports.add(attemptReport); @@ -223,7 +223,7 @@ public void testGetContainerReport() throws Exception { ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( applicationId, 1); - ContainerId containerId = ContainerId.newInstance(attemptId, 1); + ContainerId containerId = ContainerId.newContainerId(attemptId, 1); ContainerReport container = ContainerReport.newInstance(containerId, null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234, 5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE); @@ -255,8 +255,8 @@ public void testGetContainers() throws Exception { ApplicationId applicationId = ApplicationId.newInstance(1234, 5); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( applicationId, 1); - ContainerId containerId = ContainerId.newInstance(attemptId, 1); - ContainerId containerId1 = ContainerId.newInstance(attemptId, 2); + ContainerId containerId = ContainerId.newContainerId(attemptId, 1); + ContainerId containerId1 = ContainerId.newContainerId(attemptId, 2); ContainerReport container = ContainerReport.newInstance(containerId, null, NodeId.newInstance("host", 1234), Priority.UNDEFINED, 1234, 5678, "diagnosticInfo", "logURL", 0, ContainerState.COMPLETE); @@ -766,7 +766,7 @@ public void testContainersHelpCommand() throws Exception { sysOutStream.toString()); sysOutStream.reset(); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 7); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 7); result = cli.run( new String[] { "container", "-status", containerId.toString(), "args" }); verify(spyCli).printUsage(any(String.class), any(Options.class)); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java index 45b2a06429a0b..e2071ddc494e1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestContainerLaunchRPC.java @@ -97,7 +97,7 @@ private void testRPCTimeout(String rpcClass) throws Exception { ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 0); ContainerId containerId = - ContainerId.newInstance(applicationAttemptId, 100); + ContainerId.newContainerId(applicationAttemptId, 100); NodeId nodeId = NodeId.newInstance("localhost", 1234); Resource resource = Resource.newInstance(1234, 2); ContainerTokenIdentifier containerTokenIdentifier = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java index 8271713e26fad..39e616229de17 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/TestRPC.java @@ -124,7 +124,7 @@ private void test(String rpcClass) throws Exception { ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 0); ContainerId containerId = - ContainerId.newInstance(applicationAttemptId, 100); + ContainerId.newContainerId(applicationAttemptId, 100); NodeId nodeId = NodeId.newInstance("localhost", 1234); Resource resource = Resource.newInstance(1234, 2); ContainerTokenIdentifier containerTokenIdentifier = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java index 2259294bc0fae..1643301072b81 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerId.java @@ -79,6 +79,6 @@ public static ContainerId newContainerId(int appId, int appAttemptId, ApplicationId applicationId = ApplicationId.newInstance(timestamp, appId); ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, appAttemptId); - return ContainerId.newInstance(applicationAttemptId, containerId); + return ContainerId.newContainerId(applicationAttemptId, containerId); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceDecrease.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceDecrease.java index f497d27a0ca18..29b0ffe38f27d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceDecrease.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceDecrease.java @@ -33,7 +33,7 @@ public class TestContainerResourceDecrease { @Test public void testResourceDecreaseContext() { ContainerId containerId = ContainerId - .newInstance(ApplicationAttemptId.newInstance( + .newContainerId(ApplicationAttemptId.newInstance( ApplicationId.newInstance(1234, 3), 3), 7); Resource resource = Resource.newInstance(1023, 3); ContainerResourceDecrease ctx = ContainerResourceDecrease.newInstance( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncrease.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncrease.java index d307e390afb37..932d5a7a87ccf 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncrease.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncrease.java @@ -38,7 +38,7 @@ public void testResourceIncreaseContext() { byte[] identifier = new byte[] { 1, 2, 3, 4 }; Token token = Token.newInstance(identifier, "", "".getBytes(), ""); ContainerId containerId = ContainerId - .newInstance(ApplicationAttemptId.newInstance( + .newContainerId(ApplicationAttemptId.newInstance( ApplicationId.newInstance(1234, 3), 3), 7); Resource resource = Resource.newInstance(1023, 3); ContainerResourceIncrease ctx = ContainerResourceIncrease.newInstance( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncreaseRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncreaseRequest.java index 0acad00d7e96f..cf4dabf71bede 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncreaseRequest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/api/TestContainerResourceIncreaseRequest.java @@ -33,7 +33,7 @@ public class TestContainerResourceIncreaseRequest { @Test public void ContainerResourceIncreaseRequest() { ContainerId containerId = ContainerId - .newInstance(ApplicationAttemptId.newInstance( + .newContainerId(ApplicationAttemptId.newInstance( ApplicationId.newInstance(1234, 3), 3), 7); Resource resource = Resource.newInstance(1023, 3); ContainerResourceIncreaseRequest context = ContainerResourceIncreaseRequest diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java index 405cb3d52a500..4301bc9eee7d0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogFormat.java @@ -295,7 +295,7 @@ public void testContainerLogsFileAccess() throws IOException { ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 1); ContainerId testContainerId1 = - ContainerId.newInstance(applicationAttemptId, 1); + ContainerId.newContainerId(applicationAttemptId, 1); Path appDir = new Path(srcFileRoot, testContainerId1.getApplicationAttemptId() .getApplicationId().toString()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogsBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogsBlock.java index 0a17433c44fca..2a5762c30228a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogsBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/TestAggregatedLogsBlock.java @@ -207,7 +207,7 @@ private void writeLog(Configuration configuration, String user) throws Exception { ApplicationId appId = ApplicationIdPBImpl.newInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptIdPBImpl.newInstance(appId, 1); - ContainerId containerId = ContainerIdPBImpl.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerIdPBImpl.newContainerId(appAttemptId, 1); String path = "target/logs/" + user + "/logs/application_0_0001/localhost_1234"; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java index dc4f9e2a41dd8..834dcf131c498 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java @@ -134,7 +134,7 @@ public void testClientToAMTokenIdentifier() throws IOException { @Test public void testContainerTokenIdentifier() throws IOException { - ContainerId containerID = ContainerId.newInstance( + ContainerId containerID = ContainerId.newContainerId( ApplicationAttemptId.newInstance(ApplicationId.newInstance( 1, 1), 1), 1); String hostName = "host0"; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryStoreTestUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryStoreTestUtils.java index 1708da250f901..de4051a494c4f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryStoreTestUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryStoreTestUtils.java @@ -58,7 +58,7 @@ protected void writeApplicationAttemptStartData( ApplicationAttemptId appAttemptId) throws IOException { store.applicationAttemptStarted(ApplicationAttemptStartData.newInstance( appAttemptId, appAttemptId.toString(), 0, - ContainerId.newInstance(appAttemptId, 1))); + ContainerId.newContainerId(appAttemptId, 1))); } protected void writeApplicationAttemptFinishData( diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java index 60027e9283a83..7c2593d9e0aca 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryClientService.java @@ -142,7 +142,7 @@ public void testContainerReport() throws IOException, YarnException { ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); GetContainerReportRequest request = GetContainerReportRequest.newInstance(containerId); GetContainerReportResponse response = @@ -160,8 +160,8 @@ public void testContainers() throws IOException, YarnException { ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); - ContainerId containerId1 = ContainerId.newInstance(appAttemptId, 2); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); + ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 2); GetContainersRequest request = GetContainersRequest.newInstance(appAttemptId); GetContainersResponse response = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java index 856b88d28e65c..a093f19f9eaf1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestApplicationHistoryManagerOnTimelineStore.java @@ -141,7 +141,7 @@ private static void prepareTimelineStore(TimelineStore store, int scale) store.put(entities); for (int k = 1; k <= scale; ++k) { entities = new TimelineEntities(); - ContainerId containerId = ContainerId.newInstance(appAttemptId, k); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, k); entities.addEntity(createContainerEntity(containerId)); store.put(entities); } @@ -238,7 +238,7 @@ public ApplicationAttemptReport run() throws Exception { } Assert.assertNotNull(appAttempt); Assert.assertEquals(appAttemptId, appAttempt.getApplicationAttemptId()); - Assert.assertEquals(ContainerId.newInstance(appAttemptId, 1), + Assert.assertEquals(ContainerId.newContainerId(appAttemptId, 1), appAttempt.getAMContainerId()); Assert.assertEquals("test host", appAttempt.getHost()); Assert.assertEquals(100, appAttempt.getRpcPort()); @@ -253,7 +253,7 @@ public ApplicationAttemptReport run() throws Exception { @Test public void testGetContainerReport() throws Exception { final ContainerId containerId = - ContainerId.newInstance(ApplicationAttemptId.newInstance( + ContainerId.newContainerId(ApplicationAttemptId.newInstance( ApplicationId.newInstance(0, 1), 1), 1); ContainerReport container; if (callerUGI == null) { @@ -466,7 +466,7 @@ private static TimelineEntity createAppAttemptTimelineEntity( eventInfo.put(AppAttemptMetricsConstants.HOST_EVENT_INFO, "test host"); eventInfo.put(AppAttemptMetricsConstants.RPC_PORT_EVENT_INFO, 100); eventInfo.put(AppAttemptMetricsConstants.MASTER_CONTAINER_EVENT_INFO, - ContainerId.newInstance(appAttemptId, 1)); + ContainerId.newContainerId(appAttemptId, 1)); tEvent.setEventInfo(eventInfo); entity.addEvent(tEvent); tEvent = new TimelineEvent(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java index 3a75d9e275733..c91d9f5a6d5ad 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestFileSystemApplicationHistoryStore.java @@ -121,7 +121,7 @@ private void testWriteHistoryData( } // write container history data for (int k = 1; k <= num; ++k) { - ContainerId containerId = ContainerId.newInstance(appAttemptId, k); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, k); writeContainerStartData(containerId); if (missingContainer && k == num) { continue; @@ -172,7 +172,7 @@ private void testReadHistoryData( // read container history data Assert.assertEquals(num, store.getContainers(appAttemptId).size()); for (int k = 1; k <= num; ++k) { - ContainerId containerId = ContainerId.newInstance(appAttemptId, k); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, k); ContainerHistoryData containerData = store.getContainer(containerId); Assert.assertNotNull(containerData); Assert.assertEquals(Priority.newInstance(containerId.getId()), @@ -187,7 +187,7 @@ private void testReadHistoryData( ContainerHistoryData masterContainer = store.getAMContainer(appAttemptId); Assert.assertNotNull(masterContainer); - Assert.assertEquals(ContainerId.newInstance(appAttemptId, 1), + Assert.assertEquals(ContainerId.newContainerId(appAttemptId, 1), masterContainer.getContainerId()); } } @@ -215,7 +215,7 @@ public void testWriteAfterApplicationFinish() throws IOException { Assert.assertTrue(e.getMessage().contains("is not opened")); } // write container history data - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); try { writeContainerStartData(containerId); Assert.fail(); @@ -240,7 +240,7 @@ public void testMassiveWriteContainerHistoryData() throws IOException { ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); for (int i = 1; i <= 100000; ++i) { - ContainerId containerId = ContainerId.newInstance(appAttemptId, i); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, i); writeContainerStartData(containerId); writeContainerFinishData(containerId); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java index 6e9e242637a17..556db2beaf4b8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/TestMemoryApplicationHistoryStore.java @@ -137,7 +137,7 @@ public void testReadWriteContainerHistory() throws Exception { ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); try { writeContainerFinishData(containerId); Assert.fail(); @@ -149,14 +149,14 @@ public void testReadWriteContainerHistory() throws Exception { writeApplicationAttemptStartData(appAttemptId); int numContainers = 5; for (int i = 1; i <= numContainers; ++i) { - containerId = ContainerId.newInstance(appAttemptId, i); + containerId = ContainerId.newContainerId(appAttemptId, i); writeContainerStartData(containerId); writeContainerFinishData(containerId); } Assert .assertEquals(numContainers, store.getContainers(appAttemptId).size()); for (int i = 1; i <= numContainers; ++i) { - containerId = ContainerId.newInstance(appAttemptId, i); + containerId = ContainerId.newContainerId(appAttemptId, i); ContainerHistoryData data = store.getContainer(containerId); Assert.assertNotNull(data); Assert.assertEquals(Priority.newInstance(containerId.getId()), @@ -165,11 +165,11 @@ public void testReadWriteContainerHistory() throws Exception { } ContainerHistoryData masterContainer = store.getAMContainer(appAttemptId); Assert.assertNotNull(masterContainer); - Assert.assertEquals(ContainerId.newInstance(appAttemptId, 1), + Assert.assertEquals(ContainerId.newContainerId(appAttemptId, 1), masterContainer.getContainerId()); writeApplicationAttemptFinishData(appAttemptId); // Write again - containerId = ContainerId.newInstance(appAttemptId, 1); + containerId = ContainerId.newContainerId(appAttemptId, 1); try { writeContainerStartData(containerId); Assert.fail(); @@ -194,7 +194,7 @@ public void testMassiveWriteContainerHistory() throws IOException { ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); for (int i = 1; i <= numContainers; ++i) { - ContainerId containerId = ContainerId.newInstance(appAttemptId, i); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, i); writeContainerStartData(containerId); writeContainerFinishData(containerId); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebApp.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebApp.java index 82c42766b6694..7bac6f265c256 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebApp.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebApp.java @@ -134,7 +134,7 @@ public void testContainerPage() throws Exception { containerPageInstance.set( YarnWebParams.CONTAINER_ID, ContainerId - .newInstance( + .newContainerId( ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1), 1).toString()); containerPageInstance.render(); @@ -153,7 +153,7 @@ ApplicationHistoryManager mockApplicationHistoryManager(int numApps, ApplicationAttemptId.newInstance(appId, j); writeApplicationAttemptStartData(appAttemptId); for (int k = 1; k <= numContainers; ++k) { - ContainerId containerId = ContainerId.newInstance(appAttemptId, k); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, k); writeContainerStartData(containerId); writeContainerFinishData(containerId); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java index da39ce3928bd0..76bf8c3c75594 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java @@ -338,7 +338,7 @@ public void testSingleContainer() throws Exception { ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 1); WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("applicationhistory").path("apps") diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/BuilderUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/BuilderUtils.java index 8f042a87aa36c..a7e5d9cd82081 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/BuilderUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/utils/BuilderUtils.java @@ -139,7 +139,7 @@ public static ApplicationId convert(long clustertimestamp, CharSequence id) { public static ContainerId newContainerId(ApplicationAttemptId appAttemptId, long containerId) { - return ContainerId.newInstance(appAttemptId, containerId); + return ContainerId.newContainerId(appAttemptId, containerId); } public static ContainerId newContainerId(int appId, int appAttemptId, @@ -164,7 +164,7 @@ public static Token newContainerToken(ContainerId cId, String host, public static ContainerId newContainerId(RecordFactory recordFactory, ApplicationId appId, ApplicationAttemptId appAttemptId, int containerId) { - return ContainerId.newInstance(appAttemptId, containerId); + return ContainerId.newContainerId(appAttemptId, containerId); } public static NodeId newNodeId(String host, int port) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java index da25aa275a543..20983b6109ffb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/TestYarnServerApiClasses.java @@ -223,7 +223,7 @@ private ApplicationAttemptId getApplicationAttemptId(int appAttemptId) { } private ContainerId getContainerId(int containerID, int appAttemptId) { - ContainerId containerId = ContainerIdPBImpl.newInstance( + ContainerId containerId = ContainerIdPBImpl.newContainerId( getApplicationAttemptId(appAttemptId), containerID); return containerId; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/api/protocolrecords/TestProtocolRecords.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/api/protocolrecords/TestProtocolRecords.java index ed902baa7ead2..86e49f05e1de5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/api/protocolrecords/TestProtocolRecords.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/api/protocolrecords/TestProtocolRecords.java @@ -51,7 +51,7 @@ public class TestProtocolRecords { public void testNMContainerStatus() { ApplicationId appId = ApplicationId.newInstance(123456789, 1); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(attemptId, 1); + ContainerId containerId = ContainerId.newContainerId(attemptId, 1); Resource resource = Resource.newInstance(1000, 200); NMContainerStatus report = @@ -76,7 +76,7 @@ public void testNMContainerStatus() { public void testRegisterNodeManagerRequest() { ApplicationId appId = ApplicationId.newInstance(123456789, 1); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(attemptId, 1); + ContainerId containerId = ContainerId.newContainerId(attemptId, 1); NMContainerStatus containerReport = NMContainerStatus.newInstance(containerId, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/api/protocolrecords/TestRegisterNodeManagerRequest.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/api/protocolrecords/TestRegisterNodeManagerRequest.java index fdacd924d9b1c..947dec19745f1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/api/protocolrecords/TestRegisterNodeManagerRequest.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/test/java/org/apache/hadoop/yarn/server/api/protocolrecords/TestRegisterNodeManagerRequest.java @@ -38,7 +38,7 @@ public void testRegisterNodeManagerRequest() { RegisterNodeManagerRequest.newInstance( NodeId.newInstance("host", 1234), 1234, Resource.newInstance(0, 0), "version", Arrays.asList(NMContainerStatus.newInstance( - ContainerId.newInstance( + ContainerId.newContainerId( ApplicationAttemptId.newInstance( ApplicationId.newInstance(1234L, 1), 1), 1), ContainerState.RUNNING, Resource.newInstance(1024, 1), "good", -1, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestEventFlow.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestEventFlow.java index fabb03bf3f6fb..d2caefe88fed7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestEventFlow.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestEventFlow.java @@ -139,7 +139,7 @@ public long getRMIdentifier() { ApplicationId applicationId = ApplicationId.newInstance(0, 0); ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 0); - ContainerId cID = ContainerId.newInstance(applicationAttemptId, 0); + ContainerId cID = ContainerId.newContainerId(applicationAttemptId, 0); String user = "testing"; StartContainerRequest scRequest = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutor.java index ff477a38ec704..f837bbc72d293 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestLinuxContainerExecutor.java @@ -431,7 +431,7 @@ public void testPostExecuteAfterReacquisition() throws Exception { ApplicationId appId = ApplicationId.newInstance(12345, 67890); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 54321); - ContainerId cid = ContainerId.newInstance(attemptId, 9876); + ContainerId cid = ContainerId.newContainerId(attemptId, 9876); Configuration conf = new YarnConfiguration(); conf.setClass(YarnConfiguration.NM_LINUX_CONTAINER_RESOURCES_HANDLER, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerReboot.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerReboot.java index e9aea0ef6c43d..41c16a9d8fc0d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerReboot.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerReboot.java @@ -290,7 +290,7 @@ private ContainerId createContainerId() { ApplicationId appId = ApplicationId.newInstance(0, 0); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 0); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 0); return containerId; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java index 85bafb3dee585..a58294fe48156 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerResync.java @@ -592,7 +592,7 @@ public static NMContainerStatus createNMContainerStatus(int id, ApplicationId applicationId = ApplicationId.newInstance(0, 1); ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 1); - ContainerId containerId = ContainerId.newInstance(applicationAttemptId, id); + ContainerId containerId = ContainerId.newContainerId(applicationAttemptId, id); NMContainerStatus containerReport = NMContainerStatus.newInstance(containerId, containerState, Resource.newInstance(1024, 1), "recover container", 0, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerShutdown.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerShutdown.java index 11575b8373399..c079006ac10aa 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerShutdown.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeManagerShutdown.java @@ -260,7 +260,7 @@ public static ContainerId createContainerId() { ApplicationId appId = ApplicationId.newInstance(0, 0); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 0); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 0); return containerId; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java index 925a249ed1cbc..b34262b461d78 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/TestNodeStatusUpdater.java @@ -224,7 +224,7 @@ public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) ApplicationAttemptId appAttemptID = ApplicationAttemptId.newInstance(appId1, 0); ContainerId firstContainerID = - ContainerId.newInstance(appAttemptID, heartBeatID); + ContainerId.newContainerId(appAttemptID, heartBeatID); ContainerLaunchContext launchContext = recordFactory .newRecordInstance(ContainerLaunchContext.class); Resource resource = BuilderUtils.newResource(2, 1); @@ -254,7 +254,7 @@ public NodeHeartbeatResponse nodeHeartbeat(NodeHeartbeatRequest request) ApplicationAttemptId appAttemptID = ApplicationAttemptId.newInstance(appId2, 0); ContainerId secondContainerID = - ContainerId.newInstance(appAttemptID, heartBeatID); + ContainerId.newContainerId(appAttemptID, heartBeatID); ContainerLaunchContext launchContext = recordFactory .newRecordInstance(ContainerLaunchContext.class); long currentTime = System.currentTimeMillis(); @@ -818,7 +818,7 @@ public void testRecentlyFinishedContainers() throws Exception { ApplicationId appId = ApplicationId.newInstance(0, 0); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 0); - ContainerId cId = ContainerId.newInstance(appAttemptId, 0); + ContainerId cId = ContainerId.newContainerId(appAttemptId, 0); nm.getNMContext().getApplications().putIfAbsent(appId, mock(Application.class)); nm.getNMContext().getContainers().putIfAbsent(cId, mock(Container.class)); @@ -855,7 +855,7 @@ public void testRemovePreviousCompletedContainersFromContext() throws Exception ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 0); - ContainerId cId = ContainerId.newInstance(appAttemptId, 1); + ContainerId cId = ContainerId.newContainerId(appAttemptId, 1); Token containerToken = BuilderUtils.newContainerToken(cId, "anyHost", 1234, "anyUser", BuilderUtils.newResource(1024, 1), 0, 123, @@ -876,7 +876,7 @@ public org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Cont }; ContainerId runningContainerId = - ContainerId.newInstance(appAttemptId, 3); + ContainerId.newContainerId(appAttemptId, 3); Token runningContainerToken = BuilderUtils.newContainerToken(runningContainerId, "anyHost", 1234, "anyUser", BuilderUtils.newResource(1024, 1), 0, 123, @@ -936,7 +936,7 @@ public void testCleanedupApplicationContainerCleanup() throws IOException { ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 0); - ContainerId cId = ContainerId.newInstance(appAttemptId, 1); + ContainerId cId = ContainerId.newContainerId(appAttemptId, 1); Token containerToken = BuilderUtils.newContainerToken(cId, "anyHost", 1234, "anyUser", BuilderUtils.newResource(1024, 1), 0, 123, @@ -1494,7 +1494,7 @@ public static ContainerStatus createContainerStatus(int id, ApplicationId applicationId = ApplicationId.newInstance(0, 1); ApplicationAttemptId applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 1); - ContainerId contaierId = ContainerId.newInstance(applicationAttemptId, id); + ContainerId contaierId = ContainerId.newContainerId(applicationAttemptId, id); ContainerStatus containerStatus = BuilderUtils.newContainerStatus(contaierId, containerState, "test_containerStatus: id=" + id + ", containerState: " diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java index 59cc947e3b5d0..757cdc8f3ee63 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java @@ -189,7 +189,7 @@ public void testAuxEventDispatch() { ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId1, 1); ContainerTokenIdentifier cti = new ContainerTokenIdentifier( - ContainerId.newInstance(attemptId, 1), "", "", + ContainerId.newContainerId(attemptId, 1), "", "", Resource.newInstance(1, 1), 0,0,0, Priority.newInstance(0), 0); Container container = new ContainerImpl(null, null, null, null, null, null, cti); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java index 45d9925a61c87..86cc4dcedeb8b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManager.java @@ -104,7 +104,7 @@ private ContainerId createContainerId(int id) { ApplicationId appId = ApplicationId.newInstance(0, 0); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId containerId = ContainerId.newInstance(appAttemptId, id); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, id); return containerId; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManagerRecovery.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManagerRecovery.java index 007fc36fcde75..a73d58341bbdf 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManagerRecovery.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestContainerManagerRecovery.java @@ -111,7 +111,7 @@ public void testApplicationRecovery() throws Exception { ApplicationId appId = ApplicationId.newInstance(0, 1); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId cid = ContainerId.newInstance(attemptId, 1); + ContainerId cid = ContainerId.newContainerId(attemptId, 1); Map<String, LocalResource> localResources = Collections.emptyMap(); Map<String, String> containerEnv = Collections.emptyMap(); List<String> containerCmds = Collections.emptyList(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java index 001643b434ed9..cbc41c411ed3e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/launcher/TestContainerLaunch.java @@ -385,7 +385,7 @@ public void testContainerEnvVariables() throws Exception { ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId cId = ContainerId.newInstance(appAttemptId, 0); + ContainerId cId = ContainerId.newContainerId(appAttemptId, 0); Map<String, String> userSetEnv = new HashMap<String, String>(); userSetEnv.put(Environment.CONTAINER_ID.name(), "user_set_container_id"); userSetEnv.put(Environment.NM_HOST.name(), "user_set_NM_HOST"); @@ -634,7 +634,7 @@ private void internalKillTest(boolean delayed) throws Exception { ApplicationId appId = ApplicationId.newInstance(1, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId cId = ContainerId.newInstance(appAttemptId, 0); + ContainerId cId = ContainerId.newContainerId(appAttemptId, 0); File processStartFile = new File(tmpDir, "pid.txt").getAbsoluteFile(); @@ -771,7 +771,7 @@ public void testImmediateKill() throws Exception { @Test (timeout = 10000) public void testCallFailureWithNullLocalizedResources() { Container container = mock(Container.class); - when(container.getContainerId()).thenReturn(ContainerId.newInstance( + when(container.getContainerId()).thenReturn(ContainerId.newContainerId( ApplicationAttemptId.newInstance(ApplicationId.newInstance( System.currentTimeMillis(), 1), 1), 1)); ContainerLaunchContext clc = mock(ContainerLaunchContext.class); @@ -980,7 +980,7 @@ public void testKillProcessGroup() throws Exception { ApplicationId appId = ApplicationId.newInstance(2, 2); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId cId = ContainerId.newInstance(appAttemptId, 0); + ContainerId cId = ContainerId.newContainerId(appAttemptId, 0); File processStartFile = new File(tmpDir, "pid.txt").getAbsoluteFile(); File childProcessStartFile = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java index 99d722f9c7a38..1f2d0677c5f7a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/TestContainersMonitor.java @@ -206,7 +206,7 @@ public void testContainerKillOnMemoryOverflow() throws IOException, // ////// Construct the Container-id ApplicationId appId = ApplicationId.newInstance(0, 0); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 1); - ContainerId cId = ContainerId.newInstance(appAttemptId, 0); + ContainerId cId = ContainerId.newContainerId(appAttemptId, 0); int port = 12345; URL resource_alpha = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/recovery/TestNMLeveldbStateStoreService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/recovery/TestNMLeveldbStateStoreService.java index db377f5f0c7ca..438cec3a793a7 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/recovery/TestNMLeveldbStateStoreService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/recovery/TestNMLeveldbStateStoreService.java @@ -226,7 +226,7 @@ public void testContainerStorage() throws IOException { ApplicationId appId = ApplicationId.newInstance(1234, 3); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 4); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 5); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 5); LocalResource lrsrc = LocalResource.newInstance( URL.newInstance("hdfs", "somehost", 12345, "/some/path/to/rsrc"), LocalResourceType.FILE, LocalResourceVisibility.APPLICATION, 123L, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java index c07882da0ad8f..891130f0f7616 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestApplicationCleanup.java @@ -378,7 +378,7 @@ public void testAppCleanupWhenRMRestartedBeforeAppFinished() throws Exception { // nm1/nm2 register to rm2, and do a heartbeat nm1.setResourceTrackerService(rm2.getResourceTrackerService()); nm1.registerNode(Arrays.asList(NMContainerStatus.newInstance( - ContainerId.newInstance(am0.getApplicationAttemptId(), 1), + ContainerId.newContainerId(am0.getApplicationAttemptId(), 1), ContainerState.COMPLETE, Resource.newInstance(1024, 1), "", 0, Priority.newInstance(0), 1234)), Arrays.asList(app0.getApplicationId())); nm2.setResourceTrackerService(rm2.getResourceTrackerService()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java index 5652b6ea68295..15aca428268e3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestClientRMService.java @@ -404,7 +404,7 @@ public void testGetContainerReport() throws YarnException, IOException { .newRecordInstance(GetContainerReportRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); - ContainerId containerId = ContainerId.newInstance(attemptId, 1); + ContainerId containerId = ContainerId.newContainerId(attemptId, 1); request.setContainerId(containerId); try { @@ -425,7 +425,7 @@ public void testGetContainers() throws YarnException, IOException { .newRecordInstance(GetContainersRequest.class); ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance( ApplicationId.newInstance(123456, 1), 1); - ContainerId containerId = ContainerId.newInstance(attemptId, 1); + ContainerId containerId = ContainerId.newContainerId(attemptId, 1); request.setApplicationAttemptId(attemptId); try { GetContainersResponse response = rmService.getContainers(request); @@ -1213,7 +1213,7 @@ public ApplicationReport createAndGetApplicationReport( RMAppAttemptImpl rmAppAttemptImpl = spy(new RMAppAttemptImpl(attemptId, rmContext, yarnScheduler, null, asContext, config, false, null)); Container container = Container.newInstance( - ContainerId.newInstance(attemptId, 1), null, "", null, null, null); + ContainerId.newContainerId(attemptId, 1), null, "", null, null, null); RMContainerImpl containerimpl = spy(new RMContainerImpl(container, attemptId, null, "", rmContext)); Map<ApplicationAttemptId, RMAppAttempt> attempts = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestContainerResourceUsage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestContainerResourceUsage.java index c200df46c70fd..b9397bf070f20 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestContainerResourceUsage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestContainerResourceUsage.java @@ -207,7 +207,7 @@ public void testUsageWithMultipleContainersAndRMRestart() throws Exception { // usage metrics. This will cause the attempt to fail, and, since the max // attempt retries is 1, the app will also fail. This is intentional so // that all containers will complete prior to saving. - ContainerId cId = ContainerId.newInstance(attempt0.getAppAttemptId(), 1); + ContainerId cId = ContainerId.newContainerId(attempt0.getAppAttemptId(), 1); nm.nodeHeartbeat(attempt0.getAppAttemptId(), cId.getContainerId(), ContainerState.COMPLETE); rm0.waitForState(nm, cId, RMContainerState.COMPLETED); @@ -289,7 +289,7 @@ private void amRestartTests(boolean keepRunningContainers) // launch the 2nd container. ContainerId containerId2 = - ContainerId.newInstance(am0.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am0.getApplicationAttemptId(), 2); nm.nodeHeartbeat(am0.getApplicationAttemptId(), containerId2.getContainerId(), ContainerState.RUNNING); rm.waitForState(nm, containerId2, RMContainerState.RUNNING); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java index a9683f13dfc13..a0f86272b782d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestRMRestart.java @@ -1963,7 +1963,7 @@ private void writeToHostsFile(String... hosts) throws IOException { public static NMContainerStatus createNMContainerStatus( ApplicationAttemptId appAttemptId, int id, ContainerState containerState) { - ContainerId containerId = ContainerId.newInstance(appAttemptId, id); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, id); NMContainerStatus containerReport = NMContainerStatus.newInstance(containerId, containerState, Resource.newInstance(1024, 1), "recover container", 0, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java index 28d1d6383d37a..7c128481c73b8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestResourceTrackerService.java @@ -510,7 +510,7 @@ public void testHandleContainerStatusInvalidCompletions() throws Exception { // Case 1.1: AppAttemptId is null NMContainerStatus report = NMContainerStatus.newInstance( - ContainerId.newInstance( + ContainerId.newContainerId( ApplicationAttemptId.newInstance(app.getApplicationId(), 2), 1), ContainerState.COMPLETE, Resource.newInstance(1024, 1), "Dummy Completed", 0, Priority.newInstance(10), 1234); @@ -522,7 +522,7 @@ public void testHandleContainerStatusInvalidCompletions() throws Exception { (RMAppAttemptImpl) app.getCurrentAppAttempt(); currentAttempt.setMasterContainer(null); report = NMContainerStatus.newInstance( - ContainerId.newInstance(currentAttempt.getAppAttemptId(), 0), + ContainerId.newContainerId(currentAttempt.getAppAttemptId(), 0), ContainerState.COMPLETE, Resource.newInstance(1024, 1), "Dummy Completed", 0, Priority.newInstance(10), 1234); rm.getResourceTrackerService().handleNMContainerStatus(report, null); @@ -533,7 +533,7 @@ public void testHandleContainerStatusInvalidCompletions() throws Exception { // Case 2.1: AppAttemptId is null report = NMContainerStatus.newInstance( - ContainerId.newInstance( + ContainerId.newContainerId( ApplicationAttemptId.newInstance(app.getApplicationId(), 2), 1), ContainerState.COMPLETE, Resource.newInstance(1024, 1), "Dummy Completed", 0, Priority.newInstance(10), 1234); @@ -549,7 +549,7 @@ public void testHandleContainerStatusInvalidCompletions() throws Exception { (RMAppAttemptImpl) app.getCurrentAppAttempt(); currentAttempt.setMasterContainer(null); report = NMContainerStatus.newInstance( - ContainerId.newInstance(currentAttempt.getAppAttemptId(), 0), + ContainerId.newContainerId(currentAttempt.getAppAttemptId(), 0), ContainerState.COMPLETE, Resource.newInstance(1024, 1), "Dummy Completed", 0, Priority.newInstance(10), 1234); try { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestWorkPreservingRMRestart.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestWorkPreservingRMRestart.java index 536dbd77d318c..2f0a839e9e95c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestWorkPreservingRMRestart.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestWorkPreservingRMRestart.java @@ -849,7 +849,7 @@ public void testReleasedContainerNotRecovered() throws Exception { // try to release a container before the container is actually recovered. final ContainerId runningContainer = - ContainerId.newInstance(am1.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); am1.allocate(null, Arrays.asList(runningContainer)); // send container statuses to recover the containers diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/TestRMApplicationHistoryWriter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/TestRMApplicationHistoryWriter.java index 78077d4fa3416..f827bf4285d69 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/TestRMApplicationHistoryWriter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/ahs/TestRMApplicationHistoryWriter.java @@ -153,7 +153,7 @@ private static RMAppAttempt createRMAppAttempt( when(appAttempt.getRpcPort()).thenReturn(-100); Container container = mock(Container.class); when(container.getId()) - .thenReturn(ContainerId.newInstance(appAttemptId, 1)); + .thenReturn(ContainerId.newContainerId(appAttemptId, 1)); when(appAttempt.getMasterContainer()).thenReturn(container); when(appAttempt.getDiagnostics()).thenReturn("test diagnostics info"); when(appAttempt.getTrackingUrl()).thenReturn("test url"); @@ -254,7 +254,7 @@ public void testWriteApplicationAttempt() throws Exception { Assert.assertNotNull(appAttemptHD); Assert.assertEquals("test host", appAttemptHD.getHost()); Assert.assertEquals(-100, appAttemptHD.getRPCPort()); - Assert.assertEquals(ContainerId.newInstance( + Assert.assertEquals(ContainerId.newContainerId( ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1), 1), appAttemptHD.getMasterContainerId()); @@ -281,14 +281,14 @@ public void testWriteApplicationAttempt() throws Exception { @Test public void testWriteContainer() throws Exception { RMContainer container = - createRMContainer(ContainerId.newInstance( + createRMContainer(ContainerId.newContainerId( ApplicationAttemptId.newInstance(ApplicationId.newInstance(0, 1), 1), 1)); writer.containerStarted(container); ContainerHistoryData containerHD = null; for (int i = 0; i < MAX_RETRIES; ++i) { containerHD = - store.getContainer(ContainerId.newInstance(ApplicationAttemptId + store.getContainer(ContainerId.newContainerId(ApplicationAttemptId .newInstance(ApplicationId.newInstance(0, 1), 1), 1)); if (containerHD != null) { break; @@ -307,7 +307,7 @@ public void testWriteContainer() throws Exception { writer.containerFinished(container); for (int i = 0; i < MAX_RETRIES; ++i) { containerHD = - store.getContainer(ContainerId.newInstance(ApplicationAttemptId + store.getContainer(ContainerId.newContainerId(ApplicationAttemptId .newInstance(ApplicationId.newInstance(0, 1), 1), 1)); if (containerHD.getContainerState() != null) { break; @@ -337,7 +337,7 @@ public void testParallelWrite() throws Exception { RMAppAttempt appAttempt = createRMAppAttempt(appAttemptId); writer.applicationAttemptStarted(appAttempt); for (int k = 1; k <= 10; ++k) { - ContainerId containerId = ContainerId.newInstance(appAttemptId, k); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, k); RMContainer container = createRMContainer(containerId); writer.containerStarted(container); writer.containerFinished(container); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java index 800f65baaae68..62e3e5c8b9d0d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java @@ -189,7 +189,7 @@ public static RMApp newApplication(int i) { final ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(newAppID(i), 0); final Container masterContainer = Records.newRecord(Container.class); - ContainerId containerId = ContainerId.newInstance(appAttemptId, 0); + ContainerId containerId = ContainerId.newContainerId(appAttemptId, 0); masterContainer.setId(containerId); masterContainer.setNodeHttpAddress("node:port"); final String user = newUserName(); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java index fcb4e450b0890..a93123e91871d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java @@ -101,20 +101,20 @@ public void testAMRestartWithExistingContainers() throws Exception { // launch the 2nd container, for testing running container transferred. nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 2, ContainerState.RUNNING); ContainerId containerId2 = - ContainerId.newInstance(am1.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.RUNNING); // launch the 3rd container, for testing container allocated by previous // attempt is completed by the next new attempt/ nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 3, ContainerState.RUNNING); ContainerId containerId3 = - ContainerId.newInstance(am1.getApplicationAttemptId(), 3); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 3); rm1.waitForState(nm1, containerId3, RMContainerState.RUNNING); // 4th container still in AQUIRED state. for testing Acquired container is // always killed. ContainerId containerId4 = - ContainerId.newInstance(am1.getApplicationAttemptId(), 4); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 4); rm1.waitForState(nm1, containerId4, RMContainerState.ACQUIRED); // 5th container is in Allocated state. for testing allocated container is @@ -122,14 +122,14 @@ public void testAMRestartWithExistingContainers() throws Exception { am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); nm1.nodeHeartbeat(true); ContainerId containerId5 = - ContainerId.newInstance(am1.getApplicationAttemptId(), 5); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 5); rm1.waitForContainerAllocated(nm1, containerId5); rm1.waitForState(nm1, containerId5, RMContainerState.ALLOCATED); // 6th container is in Reserved state. am1.allocate("127.0.0.1", 6000, 1, new ArrayList<ContainerId>()); ContainerId containerId6 = - ContainerId.newInstance(am1.getApplicationAttemptId(), 6); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 6); nm1.nodeHeartbeat(true); SchedulerApplicationAttempt schedulerAttempt = ((AbstractYarnScheduler) rm1.getResourceScheduler()) @@ -295,12 +295,12 @@ public void testNMTokensRebindOnAMRestart() throws Exception { // launch the container-2 nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 2, ContainerState.RUNNING); ContainerId containerId2 = - ContainerId.newInstance(am1.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.RUNNING); // launch the container-3 nm1.nodeHeartbeat(am1.getApplicationAttemptId(), 3, ContainerState.RUNNING); ContainerId containerId3 = - ContainerId.newInstance(am1.getApplicationAttemptId(), 3); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 3); rm1.waitForState(nm1, containerId3, RMContainerState.RUNNING); // fail am1 @@ -335,7 +335,7 @@ public void testNMTokensRebindOnAMRestart() throws Exception { } nm1.nodeHeartbeat(am2.getApplicationAttemptId(), 2, ContainerState.RUNNING); ContainerId am2ContainerId2 = - ContainerId.newInstance(am2.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am2.getApplicationAttemptId(), 2); rm1.waitForState(nm1, am2ContainerId2, RMContainerState.RUNNING); // fail am2. @@ -379,7 +379,7 @@ public void testShouldNotCountFailureToMaxAttemptRetry() throws Exception { CapacityScheduler scheduler = (CapacityScheduler) rm1.getResourceScheduler(); ContainerId amContainer = - ContainerId.newInstance(am1.getApplicationAttemptId(), 1); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 1); // Preempt the first attempt; scheduler.killContainer(scheduler.getRMContainer(amContainer)); @@ -396,7 +396,7 @@ public void testShouldNotCountFailureToMaxAttemptRetry() throws Exception { // Preempt the second attempt. ContainerId amContainer2 = - ContainerId.newInstance(am2.getApplicationAttemptId(), 1); + ContainerId.newContainerId(am2.getApplicationAttemptId(), 1); scheduler.killContainer(scheduler.getRMContainer(amContainer2)); am2.waitForState(RMAppAttemptState.FAILED); @@ -487,7 +487,7 @@ public void testPreemptedAMRestartOnRMRestart() throws Exception { CapacityScheduler scheduler = (CapacityScheduler) rm1.getResourceScheduler(); ContainerId amContainer = - ContainerId.newInstance(am1.getApplicationAttemptId(), 1); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 1); // Forcibly preempt the am container; scheduler.killContainer(scheduler.getRMContainer(amContainer)); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/TestSystemMetricsPublisher.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/TestSystemMetricsPublisher.java index bc509a0e2508f..65c8547218097 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/TestSystemMetricsPublisher.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/metrics/TestSystemMetricsPublisher.java @@ -250,7 +250,7 @@ public void testPublishAppAttemptMetrics() throws Exception { @Test(timeout = 10000) public void testPublishContainerMetrics() throws Exception { ContainerId containerId = - ContainerId.newInstance(ApplicationAttemptId.newInstance( + ContainerId.newContainerId(ApplicationAttemptId.newInstance( ApplicationId.newInstance(0, 1), 1), 1); RMContainer container = createRMContainer(containerId); metricsPublisher.containerCreated(container, container.getCreationTime()); @@ -347,7 +347,7 @@ private static RMAppAttempt createRMAppAttempt( when(appAttempt.getRpcPort()).thenReturn(-100); Container container = mock(Container.class); when(container.getId()) - .thenReturn(ContainerId.newInstance(appAttemptId, 1)); + .thenReturn(ContainerId.newContainerId(appAttemptId, 1)); when(appAttempt.getMasterContainer()).thenReturn(container); when(appAttempt.getDiagnostics()).thenReturn("test diagnostics info"); when(appAttempt.getTrackingUrl()).thenReturn("test tracking url"); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/TestProportionalCapacityPreemptionPolicy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/TestProportionalCapacityPreemptionPolicy.java index a0c2b01607ba7..24e70bb4c9e08 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/TestProportionalCapacityPreemptionPolicy.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/monitor/capacity/TestProportionalCapacityPreemptionPolicy.java @@ -728,7 +728,7 @@ FiCaSchedulerApp mockApp(int qid, int id, int used, int pending, int reserved, RMContainer mockContainer(ApplicationAttemptId appAttId, int id, Resource r, int priority) { - ContainerId cId = ContainerId.newInstance(appAttId, id); + ContainerId cId = ContainerId.newContainerId(appAttId, id); Container c = mock(Container.class); when(c.getResource()).thenReturn(r); when(c.getPriority()).thenReturn(Priority.create(priority)); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java index e5daf6fd320ad..2b5c2b882b9ed 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/attempt/TestRMAppAttemptTransitions.java @@ -1395,7 +1395,7 @@ public void testFailedToFailed() { // failed attempt captured the container finished event. assertEquals(0, applicationAttempt.getJustFinishedContainers().size()); ContainerStatus cs2 = - ContainerStatus.newInstance(ContainerId.newInstance(appAttemptId, 2), + ContainerStatus.newInstance(ContainerId.newContainerId(appAttemptId, 2), ContainerState.COMPLETE, "", 0); applicationAttempt.handle(new RMAppAttemptContainerFinishedEvent( appAttemptId, cs2, anyNodeId)); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java index 553587ed17447..76cdcaeb0b24a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/rmcontainer/TestRMContainerImpl.java @@ -249,7 +249,7 @@ public void testExistenceOfResourceRequestInRMContainer() throws Exception { // request a container. am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); - ContainerId containerId2 = ContainerId.newInstance( + ContainerId containerId2 = ContainerId.newContainerId( am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java index c168b955c1e73..c648b83ad4bf5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerApplicationAttempt.java @@ -138,7 +138,7 @@ private RMContainer createReservedRMContainer(ApplicationAttemptId appAttId, private RMContainer createRMContainer(ApplicationAttemptId appAttId, int id, Resource resource) { - ContainerId containerId = ContainerId.newInstance(appAttId, id); + ContainerId containerId = ContainerId.newContainerId(appAttId, id); RMContainer rmContainer = mock(RMContainer.class); Container container = mock(Container.class); when(container.getResource()).thenReturn(resource); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerUtils.java index c3ae38c364a97..c9e81eebb9714 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/TestSchedulerUtils.java @@ -560,7 +560,7 @@ public void testComparePriorities(){ @Test public void testCreateAbnormalContainerStatus() { ContainerStatus cd = SchedulerUtils.createAbnormalContainerStatus( - ContainerId.newInstance(ApplicationAttemptId.newInstance( + ContainerId.newContainerId(ApplicationAttemptId.newInstance( ApplicationId.newInstance(System.currentTimeMillis(), 1), 1), 1), "x"); Assert.assertEquals(ContainerExitStatus.ABORTED, cd.getExitStatus()); } @@ -568,7 +568,7 @@ public void testCreateAbnormalContainerStatus() { @Test public void testCreatePreemptedContainerStatus() { ContainerStatus cd = SchedulerUtils.createPreemptedContainerStatus( - ContainerId.newInstance(ApplicationAttemptId.newInstance( + ContainerId.newContainerId(ApplicationAttemptId.newInstance( ApplicationId.newInstance(System.currentTimeMillis(), 1), 1), 1), "x"); Assert.assertEquals(ContainerExitStatus.PREEMPTED, cd.getExitStatus()); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java index 98dc673da2563..2aa57a0d79524 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestCapacityScheduler.java @@ -1085,7 +1085,7 @@ public void testRecoverRequestAfterPreemption() throws Exception { // request a container. am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); - ContainerId containerId1 = ContainerId.newInstance( + ContainerId containerId1 = ContainerId.newContainerId( am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId1, RMContainerState.ALLOCATED); @@ -1122,7 +1122,7 @@ public void testRecoverRequestAfterPreemption() throws Exception { } // New container will be allocated and will move to ALLOCATED state - ContainerId containerId2 = ContainerId.newInstance( + ContainerId containerId2 = ContainerId.newContainerId( am1.getApplicationAttemptId(), 3); rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java index 0c32c0cecf716..ad834ac1b3c39 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/TestContainerAllocation.java @@ -164,7 +164,7 @@ public void testContainerTokenGeneratedOnPullRequest() throws Exception { // request a container. am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); ContainerId containerId2 = - ContainerId.newInstance(am1.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED); RMContainer container = @@ -194,7 +194,7 @@ public void testNormalContainerAllocationWhenDNSUnavailable() throws Exception{ // request a container. am1.allocate("127.0.0.1", 1024, 1, new ArrayList<ContainerId>()); ContainerId containerId2 = - ContainerId.newInstance(am1.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId2, RMContainerState.ALLOCATED); // acquire the container. @@ -247,7 +247,7 @@ private LogAggregationContext getLogAggregationContextFromContainerToken( // request a container. am2.allocate("127.0.0.1", 512, 1, new ArrayList<ContainerId>()); ContainerId containerId = - ContainerId.newInstance(am2.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am2.getApplicationAttemptId(), 2); rm1.waitForState(nm1, containerId, RMContainerState.ALLOCATED); // acquire the container. @@ -480,13 +480,13 @@ public RMNodeLabelsManager createNodeLabelManager() { // A has only 10% of x, so it can only allocate one container in label=empty ContainerId containerId = - ContainerId.newInstance(am1.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), ""); Assert.assertTrue(rm1.waitForState(nm3, containerId, RMContainerState.ALLOCATED, 10 * 1000)); // Cannot allocate 2nd label=empty container containerId = - ContainerId.newInstance(am1.getApplicationAttemptId(), 3); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 3); am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), ""); Assert.assertFalse(rm1.waitForState(nm3, containerId, RMContainerState.ALLOCATED, 10 * 1000)); @@ -495,7 +495,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // We can allocate floor(8000 / 1024) = 7 containers for (int id = 3; id <= 8; id++) { containerId = - ContainerId.newInstance(am1.getApplicationAttemptId(), id); + ContainerId.newContainerId(am1.getApplicationAttemptId(), id); am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "x"); Assert.assertTrue(rm1.waitForState(nm1, containerId, RMContainerState.ALLOCATED, 10 * 1000)); @@ -571,7 +571,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // request a container (label = x && y). can only allocate on nm2 am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "x && y"); containerId = - ContainerId.newInstance(am1.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm1, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertTrue(rm1.waitForState(nm2, containerId, @@ -588,7 +588,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // and now b1's queue capacity will be used, cannot allocate more containers // (Maximum capacity reached) am2.allocate("*", 1024, 1, new ArrayList<ContainerId>()); - containerId = ContainerId.newInstance(am2.getApplicationAttemptId(), 2); + containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm4, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertFalse(rm1.waitForState(nm5, containerId, @@ -601,7 +601,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // request a container. try to allocate on nm1 (label = x) and nm3 (label = // y,z). Will successfully allocate on nm3 am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y"); - containerId = ContainerId.newInstance(am3.getApplicationAttemptId(), 2); + containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm1, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertTrue(rm1.waitForState(nm3, containerId, @@ -612,7 +612,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // try to allocate container (request label = y && z) on nm3 (label = y) and // nm4 (label = y,z). Will sucessfully allocate on nm4 only. am3.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y && z"); - containerId = ContainerId.newInstance(am3.getApplicationAttemptId(), 3); + containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 3); Assert.assertFalse(rm1.waitForState(nm3, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertTrue(rm1.waitForState(nm4, containerId, @@ -654,7 +654,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // request a container. am1.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "x"); containerId = - ContainerId.newInstance(am1.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm2, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertTrue(rm1.waitForState(nm1, containerId, @@ -669,7 +669,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // request a container. am2.allocate("*", 1024, 1, new ArrayList<ContainerId>(), "y"); - containerId = ContainerId.newInstance(am2.getApplicationAttemptId(), 2); + containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm1, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertTrue(rm1.waitForState(nm2, containerId, @@ -684,7 +684,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // request a container. am3.allocate("*", 1024, 1, new ArrayList<ContainerId>()); - containerId = ContainerId.newInstance(am3.getApplicationAttemptId(), 2); + containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm2, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertTrue(rm1.waitForState(nm3, containerId, @@ -730,7 +730,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // request a container. am1.allocate("*", 1024, 1, new ArrayList<ContainerId>()); containerId = - ContainerId.newInstance(am1.getApplicationAttemptId(), 2); + ContainerId.newContainerId(am1.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm3, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertTrue(rm1.waitForState(nm1, containerId, @@ -745,7 +745,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // request a container. am2.allocate("*", 1024, 1, new ArrayList<ContainerId>()); - containerId = ContainerId.newInstance(am2.getApplicationAttemptId(), 2); + containerId = ContainerId.newContainerId(am2.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm3, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertTrue(rm1.waitForState(nm2, containerId, @@ -760,7 +760,7 @@ public RMNodeLabelsManager createNodeLabelManager() { // request a container. am3.allocate("*", 1024, 1, new ArrayList<ContainerId>()); - containerId = ContainerId.newInstance(am3.getApplicationAttemptId(), 2); + containerId = ContainerId.newContainerId(am3.getApplicationAttemptId(), 2); Assert.assertFalse(rm1.waitForState(nm2, containerId, RMContainerState.ALLOCATED, 10 * 1000)); Assert.assertTrue(rm1.waitForState(nm3, containerId, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java index 519425145a89e..ca0e954e7290c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/TestFairScheduler.java @@ -3530,7 +3530,7 @@ public void testRecoverRequestAfterPreemption() throws Exception { // ResourceRequest will be empty once NodeUpdate is completed Assert.assertNull(app.getResourceRequest(priority, host)); - ContainerId containerId1 = ContainerId.newInstance(appAttemptId, 1); + ContainerId containerId1 = ContainerId.newContainerId(appAttemptId, 1); RMContainer rmContainer = app.getRMContainer(containerId1); // Create a preempt event and register for preemption diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java index de8d3029778d2..f0dcb562a234c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-tests/src/test/java/org/apache/hadoop/yarn/server/TestContainerManagerSecurity.java @@ -231,7 +231,7 @@ private void testNMTokens(Configuration conf) throws Exception { ApplicationAttemptId.newInstance(appId, 1); ContainerId validContainerId = - ContainerId.newInstance(validAppAttemptId, 0); + ContainerId.newContainerId(validAppAttemptId, 0); NodeId validNode = yarnCluster.getNodeManager(0).getNMContext().getNodeId(); NodeId invalidNode = NodeId.newInstance("InvalidHost", 1234); @@ -311,7 +311,7 @@ private void testNMTokens(Configuration conf) throws Exception { ApplicationAttemptId.newInstance(appId, 2); ContainerId validContainerId2 = - ContainerId.newInstance(validAppAttemptId2, 0); + ContainerId.newContainerId(validAppAttemptId2, 0); org.apache.hadoop.yarn.api.records.Token validContainerToken2 = containerTokenSecretManager.createContainerToken(validContainerId2, @@ -401,7 +401,7 @@ private void testNMTokens(Configuration conf) throws Exception { .createNMToken(validAppAttemptId, validNode, user); org.apache.hadoop.yarn.api.records.Token newContainerToken = containerTokenSecretManager.createContainerToken( - ContainerId.newInstance(attempt2, 1), validNode, user, r, + ContainerId.newContainerId(attempt2, 1), validNode, user, r, Priority.newInstance(0), 0); Assert.assertTrue(testStartContainer(rpc, attempt2, validNode, newContainerToken, attempt1NMToken, false).isEmpty()); @@ -638,7 +638,7 @@ private void testContainerToken(Configuration conf) throws IOException, ApplicationId appId = ApplicationId.newInstance(1, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 0); - ContainerId cId = ContainerId.newInstance(appAttemptId, 0); + ContainerId cId = ContainerId.newContainerId(appAttemptId, 0); NodeManager nm = yarnCluster.getNodeManager(0); NMTokenSecretManagerInNM nmTokenSecretManagerInNM = nm.getNMContext().getNMTokenSecretManager(); @@ -691,7 +691,7 @@ private void testContainerToken(Configuration conf) throws IOException, } while (containerTokenSecretManager.getCurrentKey().getKeyId() == tamperedContainerTokenSecretManager.getCurrentKey().getKeyId()); - ContainerId cId2 = ContainerId.newInstance(appAttemptId, 1); + ContainerId cId2 = ContainerId.newContainerId(appAttemptId, 1); // Creating modified containerToken Token containerToken2 = tamperedContainerTokenSecretManager.createContainerToken(cId2, nodeId, @@ -733,7 +733,7 @@ private void testContainerTokenWithEpoch(Configuration conf) ApplicationId appId = ApplicationId.newInstance(1, 1); ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(appId, 0); - ContainerId cId = ContainerId.newInstance(appAttemptId, (5L << 40) | 3L); + ContainerId cId = ContainerId.newContainerId(appAttemptId, (5L << 40) | 3L); NodeManager nm = yarnCluster.getNodeManager(0); NMTokenSecretManagerInNM nmTokenSecretManagerInNM = nm.getNMContext().getNMTokenSecretManager();
e38e4ea7a76d42692453be0288d8cf101e13fd52
Mylyn Reviews
322734: Label for review rating and comment
a
https://github.com/eclipse-mylyn/org.eclipse.mylyn.reviews
diff --git a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/editors/ReviewTaskEditorPart.java b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/editors/ReviewTaskEditorPart.java index b11d55b4..07d8d272 100644 --- a/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/editors/ReviewTaskEditorPart.java +++ b/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/reviews/ui/editors/ReviewTaskEditorPart.java @@ -59,6 +59,7 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.forms.IFormColors; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; @@ -252,16 +253,17 @@ private void createResultFields(Composite composite, FormToolkit toolkit) { Composite resultComposite = toolkit.createComposite(composite); toolkit.paintBordersFor(resultComposite); + resultComposite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, + false)); + resultComposite.setLayout(new GridLayout(2, false)); + toolkit.createLabel(resultComposite, "Rating").setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); CCombo ratingsCombo = new CCombo(resultComposite, SWT.READ_ONLY | SWT.FLAT); ratingsCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER); toolkit.adapt(ratingsCombo, false, false); - resultComposite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, - false)); - resultComposite.setLayout(new GridLayout(2, false)); final ComboViewer ratingList = new ComboViewer(ratingsCombo); ratingList.setContentProvider(ArrayContentProvider.getInstance()); @@ -291,10 +293,12 @@ public Image getImage(Object element) { ratingList.setInput(Rating.VALUES); ratingList.getControl().setLayoutData( new GridData(SWT.LEFT, SWT.TOP, false, false)); + + toolkit.createLabel(resultComposite, "Review comment").setForeground(toolkit.getColors().getColor(IFormColors.TITLE)); final Text commentText = toolkit.createText(resultComposite, "", SWT.BORDER | SWT.MULTI); GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.heightHint = 30; + gd.heightHint = 100; commentText.setLayoutData(gd); if (review.getResult() != null) {
662f0972b4af7430f6d008b933f4faa15f5788d3
orientdb
Huge refactoring on GraphDB: - changed class- names in vertex and edge - Optimized memory consumption by removing nested- records - Optimized speed in ORecord.equals() and hashCode(): now avoid field- checks (experimental)--
p
https://github.com/orientechnologies/orientdb
diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/graph/ODatabaseGraphTx.java b/core/src/main/java/com/orientechnologies/orient/core/db/graph/ODatabaseGraphTx.java index 2ceeceb3741..90204a28c4b 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/db/graph/ODatabaseGraphTx.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/graph/ODatabaseGraphTx.java @@ -38,17 +38,18 @@ public ODatabaseGraphTx(final String iURL) { } @SuppressWarnings("unchecked") - public <THISDB extends ODatabase> THISDB open(String iUserName, String iUserPassword) { + public <THISDB extends ODatabase> THISDB open(final String iUserName, final String iUserPassword) { underlying.open(iUserName, iUserPassword); - if (!underlying.getMetadata().getSchema().existsClass("OGraphNode")) { + if (!underlying.getMetadata().getSchema().existsClass(OGraphVertex.CLASS_NAME)) { final OClass node = underlying.getMetadata().getSchema() - .createClass("OGraphNode", underlying.addPhysicalCluster("OGraphNode")); - final OClass arc = underlying.getMetadata().getSchema().createClass("OGraphArc", underlying.addPhysicalCluster("OGraphArc")); + .createClass(OGraphVertex.CLASS_NAME, underlying.addPhysicalCluster(OGraphVertex.CLASS_NAME)); + final OClass arc = underlying.getMetadata().getSchema() + .createClass(OGraphEdge.CLASS_NAME, underlying.addPhysicalCluster(OGraphEdge.CLASS_NAME)); - arc.createProperty("from", OType.LINK, node); - arc.createProperty("to", OType.LINK, node); - node.createProperty("arcs", OType.EMBEDDEDLIST, arc); + arc.createProperty(OGraphEdge.SOURCE, OType.LINK, node); + arc.createProperty(OGraphEdge.DESTINATION, OType.LINK, node); + node.createProperty(OGraphVertex.FIELD_EDGES, OType.EMBEDDEDLIST, arc); underlying.getMetadata().getSchema().save(); } @@ -56,25 +57,25 @@ public <THISDB extends ODatabase> THISDB open(String iUserName, String iUserPass return (THISDB) this; } - public OGraphNode createNode() { - return new OGraphNode(this); + public OGraphVertex createVertex() { + return new OGraphVertex(this); } - public OGraphNode getRoot(final String iName) { - return new OGraphNode(underlying.getDictionary().get(iName)); + public OGraphVertex getRoot(final String iName) { + return new OGraphVertex(underlying.getDictionary().get(iName)); } - public OGraphNode getRoot(final String iName, final String iFetchPlan) { - return new OGraphNode(underlying.getDictionary().get(iName), iFetchPlan); + public OGraphVertex getRoot(final String iName, final String iFetchPlan) { + return new OGraphVertex(underlying.getDictionary().get(iName), iFetchPlan); } - public ODatabaseGraphTx setRoot(final String iName, final OGraphNode iNode) { + public ODatabaseGraphTx setRoot(final String iName, final OGraphVertex iNode) { underlying.getDictionary().put(iName, iNode.getDocument()); return this; } public OGraphElement newInstance() { - return new OGraphNode(this); + return new OGraphVertex(this); } public OGraphElement load(final OGraphElement iObject) { @@ -91,10 +92,10 @@ public OGraphElement load(final ORID iRecordId) { if (doc == null) return null; - if (doc.getClassName().equals(OGraphNode.class.getSimpleName())) - return new OGraphNode(doc); - else if (doc.getClassName().equals(OGraphArc.class.getSimpleName())) - return new OGraphArc(doc); + if (doc.getClassName().equals(OGraphVertex.class.getSimpleName())) + return new OGraphVertex(doc); + else if (doc.getClassName().equals(OGraphEdge.class.getSimpleName())) + return new OGraphEdge(doc); else throw new IllegalArgumentException("RecordID is not of supported type. Class=" + doc.getClassName()); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphArc.java b/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphEdge.java similarity index 52% rename from core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphArc.java rename to core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphEdge.java index f631d15cd1f..580f97a1505 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphArc.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphEdge.java @@ -23,44 +23,56 @@ /** * GraphDB Node. */ -public class OGraphArc extends OGraphElement { - private static final String CLASS_NAME = "OGraphArc"; - private static final String SOURCE = "source"; - private static final String DESTINATION = "destination"; +public class OGraphEdge extends OGraphElement { + public static final String CLASS_NAME = "OGraphEdge"; + public static final String SOURCE = "source"; + public static final String DESTINATION = "destination"; - private OGraphNode source; - private OGraphNode destination; + private OGraphVertex source; + private OGraphVertex destination; - public OGraphArc(final ODatabaseRecord<?> iDatabase, final ORID iRID) { + public OGraphEdge(final ODatabaseRecord<?> iDatabase, final ORID iRID) { super(iDatabase, iRID); } - public OGraphArc(final ODatabaseRecord<?> iDatabase) { + public OGraphEdge(final ODatabaseRecord<?> iDatabase) { super(iDatabase, CLASS_NAME); } - public OGraphArc(final ODatabaseRecord<?> database, final OGraphNode iSourceNode, final OGraphNode iDestinationNode) { + public OGraphEdge(final ODatabaseRecord<?> database, final OGraphVertex iSourceNode, final OGraphVertex iDestinationNode) { this(database); + source = iSourceNode; + destination = iDestinationNode; set(SOURCE, iSourceNode.getDocument()).set(DESTINATION, iDestinationNode.getDocument()); } - public OGraphArc(final ODocument iDocument) { + public OGraphEdge(final ODocument iDocument) { super(iDocument); if (iDocument.getInternalStatus() == STATUS.NOT_LOADED) iDocument.load(); } - public OGraphNode getSource() { + public OGraphVertex getSource() { if (source == null) - source = new OGraphNode((ODocument) document.field(SOURCE)); + source = new OGraphVertex((ODocument) document.field(SOURCE)); return source; } - public OGraphNode getDestination() { + public void setSource(final OGraphVertex iSource) { + this.source = iSource; + document.field(SOURCE, iSource.getDocument()); + } + + public OGraphVertex getDestination() { if (destination == null) - destination = new OGraphNode((ODocument) document.field(DESTINATION)); + destination = new OGraphVertex((ODocument) document.field(DESTINATION)); return destination; } + + public void setDestination(final OGraphVertex iDestination) { + this.destination = iDestination; + document.field(DESTINATION, iDestination.getDocument()); + } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphElement.java b/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphElement.java index 1e50d270d9b..1b480a9f866 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphElement.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphElement.java @@ -58,4 +58,34 @@ public void save() { public ODocument getDocument() { return document; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((document == null) ? 0 : document.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + OGraphElement other = (OGraphElement) obj; + if (document == null) { + if (other.document != null) + return false; + } else if (!document.equals(other.document)) + return false; + return true; + } + + @Override + public String toString() { + return document != null ? document.toString() : "?"; + } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphNode.java b/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphVertex.java similarity index 53% rename from core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphNode.java rename to core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphVertex.java index 1cb1c534dc7..f2534da418a 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphNode.java +++ b/core/src/main/java/com/orientechnologies/orient/core/db/graph/OGraphVertex.java @@ -26,62 +26,84 @@ /** * GraphDB Node. */ -public class OGraphNode extends OGraphElement { - private static final String CLASS_NAME = "OGraphNode"; +public class OGraphVertex extends OGraphElement { + public static final String CLASS_NAME = "OGraphVertex"; + public static final String FIELD_EDGES = "edges"; - private List<OGraphArc> arcs; + private List<OGraphEdge> edges; - public OGraphNode(final ODatabaseGraphTx iDatabase, final ORID iRID) { + public OGraphVertex(final ODatabaseGraphTx iDatabase, final ORID iRID) { super(new ODocument((ODatabaseRecord<?>) iDatabase.getUnderlying(), iRID)); } - public OGraphNode(final ODatabaseGraphTx iDatabase) { + public OGraphVertex(final ODatabaseGraphTx iDatabase) { super(new ODocument((ODatabaseRecord<?>) iDatabase.getUnderlying(), CLASS_NAME)); } - public OGraphNode(final ODocument iDocument) { + public OGraphVertex(final ODocument iDocument) { super(iDocument); if (iDocument.getInternalStatus() == STATUS.NOT_LOADED) iDocument.load(); } - public OGraphNode(final ODocument iDocument, final String iFetchPlan) { + public OGraphVertex(final ODocument iDocument, final String iFetchPlan) { super(iDocument); if (iDocument.getInternalStatus() == STATUS.NOT_LOADED) iDocument.load(iFetchPlan); } @SuppressWarnings("unchecked") - public OGraphArc link(final OGraphNode iDestinationNode) { + public OGraphEdge link(final OGraphVertex iDestinationNode) { if (iDestinationNode == null) throw new IllegalArgumentException("Missed the arc destination property"); - final OGraphArc arc = new OGraphArc(document.getDatabase(), this, iDestinationNode); - getArcs().add(arc); - ((List<ODocument>) document.field("arcs")).add(arc.getDocument()); + final OGraphEdge arc = new OGraphEdge(document.getDatabase(), this, iDestinationNode); + getEdges().add(arc); + ((List<ODocument>) document.field(FIELD_EDGES)).add(arc.getDocument()); return arc; } /** * Returns the arcs of current node. If there are no arcs, then an empty list is returned. */ - public List<OGraphArc> getArcs() { - if (arcs == null) { - arcs = new ArrayList<OGraphArc>(); + public List<OGraphEdge> getEdges() { + if (edges == null) { + edges = new ArrayList<OGraphEdge>(); - List<ODocument> docs = document.field("arcs"); + List<ODocument> docs = document.field(FIELD_EDGES); if (docs == null) { docs = new ArrayList<ODocument>(); - document.field("arcs", docs); + document.field(FIELD_EDGES, docs); } else { // TRANSFORM ALL THE ARCS for (ODocument d : docs) { - arcs.add(new OGraphArc(d)); + edges.add(new OGraphEdge(d)); } } } - return arcs; + return edges; + } + + @SuppressWarnings("unchecked") + public List<OGraphVertex> browseEdgeDestinations() { + final List<OGraphVertex> resultset = new ArrayList<OGraphVertex>(); + + if (edges == null) { + List<ODocument> docEdges = (List<ODocument>) document.field(FIELD_EDGES); + + // TRANSFORM ALL THE ARCS + if (docEdges != null) + for (ODocument d : docEdges) { + resultset.add(new OGraphVertex((ODocument) d.field(OGraphEdge.DESTINATION))); + } + } else { + for (OGraphEdge edge : edges) { + resultset.add(edge.getDestination()); + } + } + + return resultset; } } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/GraphTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/GraphTest.java deleted file mode 100644 index 26bcc7d3487..00000000000 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/GraphTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 1999-2010 Luca Garulli (l.garulli--at--orientechnologies.com) - * - * 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.orientechnologies.orient.test.database.auto; - -import java.util.Date; - -import org.testng.Assert; -import org.testng.annotations.Parameters; -import org.testng.annotations.Test; - -import com.orientechnologies.orient.client.remote.OEngineRemote; -import com.orientechnologies.orient.core.Orient; -import com.orientechnologies.orient.core.db.graph.ODatabaseGraphTx; -import com.orientechnologies.orient.core.db.graph.OGraphArc; -import com.orientechnologies.orient.core.db.graph.OGraphNode; - -@Test(sequential = true) -public class GraphTest { - protected static final int TOT_RECORDS = 100; - protected long startRecordNumber; - private ODatabaseGraphTx database; - - @Parameters(value = "url") - public GraphTest(String iURL) { - Orient.instance().registerEngine(new OEngineRemote()); - database = new ODatabaseGraphTx(iURL); - } - - @Test - public void populate() { - database.open("admin", "admin"); - - OGraphNode rootNode = database.createNode().set("id", 0); - - OGraphNode newNode; - OGraphNode currentNode = rootNode; - - for (int i = 1; i <= TOT_RECORDS; ++i) { - - newNode = database.createNode().set("id", i); - currentNode.link(newNode).set("createdOn", new Date()); - - currentNode = newNode; - } - - database.setRoot("test", rootNode); - - database.close(); - } - - @Test(dependsOnMethods = "populate") - public void checkPopulation() { - database.open("admin", "admin"); - - int counter = 0; - OGraphNode currentNode = database.getRoot("test"); - while (!currentNode.getArcs().isEmpty()) { - Assert.assertEquals(((Number) currentNode.get("id")).intValue(), counter); - - for (OGraphArc arc : currentNode.getArcs()) { - counter++; - currentNode = arc.getDestination(); - } - } - - Assert.assertEquals(counter, TOT_RECORDS); - - database.close(); - } -} diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/GraphTestFixedDensity.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/GraphTestFixedDensity.java new file mode 100644 index 00000000000..1619e104e4f --- /dev/null +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/GraphTestFixedDensity.java @@ -0,0 +1,110 @@ +/* + * Copyright 1999-2010 Luca Garulli (l.garulli--at--orientechnologies.com) + * + * 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.orientechnologies.orient.test.database.auto; + +import org.testng.Assert; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import com.orientechnologies.orient.client.remote.OEngineRemote; +import com.orientechnologies.orient.core.Orient; +import com.orientechnologies.orient.core.db.graph.ODatabaseGraphTx; +import com.orientechnologies.orient.core.db.graph.OGraphVertex; + +@Test(sequential = true) +public class GraphTestFixedDensity { + private static final int MAX_DEEP = 1000; + private static final int DENSITY = 1; + + private ODatabaseGraphTx database; + private int nodeWrittenCounter = 0; + private int nodeReadCounter = -1; + + @Parameters(value = "url") + public GraphTestFixedDensity(String iURL) { + Orient.instance().registerEngine(new OEngineRemote()); + database = new ODatabaseGraphTx(iURL); + } + + @Test + public void populate() { + database.open("admin", "admin"); + + long time = System.currentTimeMillis(); + + OGraphVertex rootNode = database.createVertex().set("id", 0); + + createSubNodes(rootNode, 0); + + database.setRoot("LinearGraph", rootNode); + + System.out.println("Creation of the graph with deep=" + MAX_DEEP + " and fixed density=1" + + ((System.currentTimeMillis() - time) / 1000f) + " sec."); + + database.close(); + } + + @Test(dependsOnMethods = "populate") + public void checkPopulation() { + database.open("admin", "admin"); + + long time = System.currentTimeMillis(); + + readSubNodes(database.getRoot("LinearGraph")); + + System.out.println("Read of the entire graph with deep=" + nodeReadCounter + " and fixed density=" + DENSITY + " in " + + ((System.currentTimeMillis() - time) / 1000f) + " sec."); + + Assert.assertEquals(nodeReadCounter, nodeWrittenCounter); + } + + @Test(dependsOnMethods = "populate") + public void checkPopulationHotCache() { + long time = System.currentTimeMillis(); + + nodeReadCounter = -1; + readSubNodes(database.getRoot("LinearGraph")); + + System.out.println("Read with hot cache of the entire graph with deep=" + nodeReadCounter + " and fixed density=" + DENSITY + + " in " + ((System.currentTimeMillis() - time) / 1000f) + " sec."); + + Assert.assertEquals(nodeReadCounter, nodeWrittenCounter); + + database.close(); + } + + private void readSubNodes(final OGraphVertex iNode) { + Assert.assertEquals(((Number) iNode.get("id")).intValue(), ++nodeReadCounter); + + for (OGraphVertex node : iNode.browseEdgeDestinations()) { + readSubNodes(node); + } + } + + private void createSubNodes(final OGraphVertex iNode, final int iDeepLevel) { + OGraphVertex newNode; + + for (int i = 0; i < DENSITY; ++i) { + newNode = database.createVertex().set("id", ++nodeWrittenCounter); + iNode.link(newNode); + + if (iDeepLevel < MAX_DEEP) + createSubNodes(newNode, iDeepLevel + 1); + } + + iNode.save(); + } +} diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/GraphTestVariableDensity.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/GraphTestVariableDensity.java new file mode 100644 index 00000000000..e875970ddc8 --- /dev/null +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/GraphTestVariableDensity.java @@ -0,0 +1,131 @@ +/* + * Copyright 1999-2010 Luca Garulli (l.garulli--at--orientechnologies.com) + * + * 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.orientechnologies.orient.test.database.auto; + +import org.testng.Assert; +import org.testng.annotations.Parameters; +import org.testng.annotations.Test; + +import com.orientechnologies.orient.client.remote.OEngineRemote; +import com.orientechnologies.orient.core.Orient; +import com.orientechnologies.orient.core.db.graph.ODatabaseGraphTx; +import com.orientechnologies.orient.core.db.graph.OGraphVertex; + +@Test(sequential = true) +public class GraphTestVariableDensity { + private static final int MAX_NODES = 1000000; + private static final int MAX_DEEP = 5; + private static final int START_DENSITY = 184; + private static final int DENSITY_FACTOR = 13; + + private static int nodeWrittenCounter = 0; + private static int arcWrittenCounter = 0; + private static int nodeReadCounter = 0; + private static int arcReadCounter = 0; + + private ODatabaseGraphTx database; + + @Parameters(value = "url") + public GraphTestVariableDensity(String iURL) { + Orient.instance().registerEngine(new OEngineRemote()); + database = new ODatabaseGraphTx(iURL); + } + + @Test(dependsOnMethods = "checkPopulation") + public void populateWithHighDensity() { + database.open("admin", "admin"); + + long time = System.currentTimeMillis(); + + OGraphVertex rootNode = database.createVertex().set("id", 0); + + nodeWrittenCounter = 1; + createSubNodes(rootNode, 0, START_DENSITY); + + long lap = System.currentTimeMillis(); + + database.setRoot("HighDensityGraph", rootNode); + + System.out.println("Creation of the graph with deep=" + MAX_DEEP + " and density variable <=30. Total " + nodeWrittenCounter + + " nodes and " + arcWrittenCounter + " arcs in " + ((lap - time) / 1000f) + " sec."); + database.close(); + } + + @Test(dependsOnMethods = "populateWithHighDensity") + public void checkHighDensityPopulation() { + database.open("admin", "admin"); + + long time = System.currentTimeMillis(); + + readSubNodes(database.getRoot("HighDensityGraph")); + + System.out.println("Read of the entire graph with deep=" + MAX_DEEP + " and density variable <=30 Total " + nodeReadCounter + + " nodes and " + arcReadCounter + " arcs in " + ((System.currentTimeMillis() - time) / 1000f) + " sec."); + + Assert.assertEquals(nodeReadCounter, nodeWrittenCounter); + } + + @Test(dependsOnMethods = "checkHighDensityPopulation") + public void checkHighDensityPopulationHotCache() { + + long time = System.currentTimeMillis(); + + nodeReadCounter = arcReadCounter = 0; + readSubNodes(database.getRoot("HighDensityGraph")); + + System.out.println("Read of the entire graph with deep=" + MAX_DEEP + " and density variable <=30 Total " + nodeReadCounter + + " nodes and " + arcReadCounter + " arcs in " + ((System.currentTimeMillis() - time) / 1000f) + " sec."); + + Assert.assertEquals(nodeReadCounter, nodeWrittenCounter); + + database.close(); + } + + private void readSubNodes(final OGraphVertex iNode) { + Assert.assertEquals(((Number) iNode.get("id")).intValue(), nodeReadCounter); + + nodeReadCounter++; + + for (OGraphVertex node : iNode.browseEdgeDestinations()) { + arcReadCounter++; + readSubNodes(node); + } + } + + private void createSubNodes(final OGraphVertex iNode, final int iDeepLevel, int iDensity) { + System.out.println("Creating " + iDensity + " sub nodes..."); + + OGraphVertex newNode; + + for (int i = 0; i <= iDensity && nodeWrittenCounter < MAX_NODES; ++i) { + newNode = database.createVertex().set("id", nodeWrittenCounter++); + iNode.link(newNode); + arcWrittenCounter++; + + if (iDeepLevel < MAX_DEEP) { + if (iDensity * DENSITY_FACTOR / 100 > 0) + iDensity -= iDensity * DENSITY_FACTOR / 100; + else + iDensity -= 1; + + createSubNodes(newNode, iDeepLevel + 1, iDensity); + } + } + + iNode.save(); + } + +} diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/remote-test-db-from-scratch.xml b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/remote-test-db-from-scratch.xml index b5163e9948d..43460cfeaae 100644 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/remote-test-db-from-scratch.xml +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/remote-test-db-from-scratch.xml @@ -60,6 +60,12 @@ <class name="com.orientechnologies.orient.test.database.auto.WrongQueryTest" /> </classes> </test> + <test name="Graph"> + <classes> + <class name="com.orientechnologies.orient.test.database.auto.GraphTestFixedDensity" /> + <class name="com.orientechnologies.orient.test.database.auto.GraphTestVariableDensity" /> + </classes> + </test> <test name="sql-select"> <classes> <class name="com.orientechnologies.orient.test.database.auto.SQLSelectTest" />
859d63dedffa54c64be5354d21dd494c07205ffa
Vala
gtksourceview-2.0: Make argument to gtk_source_buffer_new nullable Fixes bug 623517.
c
https://github.com/GNOME/vala/
diff --git a/vapi/gtksourceview-2.0.vapi b/vapi/gtksourceview-2.0.vapi index 1e6f70c193..3d3da821fe 100644 --- a/vapi/gtksourceview-2.0.vapi +++ b/vapi/gtksourceview-2.0.vapi @@ -5,7 +5,7 @@ namespace Gtk { [CCode (cheader_filename = "gtksourceview/gtksourceview.h")] public class SourceBuffer : Gtk.TextBuffer { [CCode (has_construct_function = false)] - public SourceBuffer (Gtk.TextTagTable table); + public SourceBuffer (Gtk.TextTagTable? table); public bool backward_iter_to_source_mark (Gtk.TextIter iter, string category); public void begin_not_undoable_action (); public unowned Gtk.SourceMark create_source_mark (string name, string category, Gtk.TextIter where); diff --git a/vapi/packages/gtksourceview-2.0/gtksourceview-2.0.metadata b/vapi/packages/gtksourceview-2.0/gtksourceview-2.0.metadata index f2c59a2053..5fb2fa99e1 100644 --- a/vapi/packages/gtksourceview-2.0/gtksourceview-2.0.metadata +++ b/vapi/packages/gtksourceview-2.0/gtksourceview-2.0.metadata @@ -9,6 +9,7 @@ gtk_source_iter_forward_search.match_end is_out="1" gtk_source_iter_forward_search.limit nullable="1" GtkSourceBuffer::redo has_emitter="1" GtkSourceBuffer::undo has_emitter="1" +gtk_source_buffer_new.table nullable="1" GtkSourceCompletion::hide has_emitter="1" GtkSourceCompletion::show has_emitter="1" GtkSourceCompletionProposal::changed has_emitter="1"
8ddd5253544c01c22d08c634b08b7fab75c86864
tapiji
Adapts the namespace of all TapiJI plug-ins to org.eclipselabs.tapiji.*.
p
https://github.com/tapiji/tapiji
diff --git a/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/.project b/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/.project index 3124a561..2fdfb19a 100644 --- a/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/.project +++ b/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/.project @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>at.ac.tuwien.inso.eclipse.i18n.jsf.feature</name> + <name>org.eclipselabs.tapiji.tools.jsf.feature</name> <comment></comment> <projects> </projects> diff --git a/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/feature.xml b/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/feature.xml index b8b17f83..aa9fa0dc 100644 --- a/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/feature.xml +++ b/at.ac.tuwien.inso.eclipse.i18n.jsf.feature/feature.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <feature - id="at.ac.tuwien.inso.eclipse.i18n.jsf.feature" + id="org.eclipselabs.tapiji.tools.jsf.feature" label="JSF Internationalization Feature" version="0.0.1.qualifier" provider-name="Vienna University of Technology" - plugin="at.ac.tuwien.inso.eclipse.i18n"> + plugin="org.eclipselabs.tapiji.tools.jsf"> <description url="http://svn.codespot.com/a/eclipselabs.org/tapiji/update/"> The TapiJI JSF Internationalization plug-in extends Internationalizaion @@ -17,341 +17,100 @@ reserved. </copyright> <license url="http://www.eclipse.org/legal/epl-v10.html"> - &lt;html xmlns:o=&quot;urn:schemas-microsoft-com:office:office&quot; -xmlns:w=&quot;urn:schemas-microsoft-com:office:word&quot; -xmlns=&quot;http://www.w3.org/TR/REC-html40&quot;&gt; - -&lt;head&gt; -&lt;meta http-equiv=Content-Type content=&quot;text/html; charset=windows-1252&quot;&gt; -&lt;meta name=ProgId content=Word.Document&gt; -&lt;meta name=Generator content=&quot;Microsoft Word 9&quot;&gt; -&lt;meta name=Originator content=&quot;Microsoft Word 9&quot;&gt; -&lt;link rel=File-List -href=&quot;./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml&quot;&gt; -&lt;title&gt;Eclipse Public License - Version 1.0&lt;/title&gt; -&lt;!--[if gte mso 9]&gt;&lt;xml&gt; - &lt;o:DocumentProperties&gt; - &lt;o:Revision&gt;2&lt;/o:Revision&gt; - &lt;o:TotalTime&gt;3&lt;/o:TotalTime&gt; - &lt;o:Created&gt;2004-03-05T23:03:00Z&lt;/o:Created&gt; - &lt;o:LastSaved&gt;2004-03-05T23:03:00Z&lt;/o:LastSaved&gt; - &lt;o:Pages&gt;4&lt;/o:Pages&gt; - &lt;o:Words&gt;1626&lt;/o:Words&gt; - &lt;o:Characters&gt;9270&lt;/o:Characters&gt; - &lt;o:Lines&gt;77&lt;/o:Lines&gt; - &lt;o:Paragraphs&gt;18&lt;/o:Paragraphs&gt; - &lt;o:CharactersWithSpaces&gt;11384&lt;/o:CharactersWithSpaces&gt; - &lt;o:Version&gt;9.4402&lt;/o:Version&gt; - &lt;/o:DocumentProperties&gt; -&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt; - &lt;w:WordDocument&gt; - &lt;w:TrackRevisions/&gt; - &lt;/w:WordDocument&gt; -&lt;/xml&gt;&lt;![endif]--&gt; -&lt;style&gt; -&lt;!-- - /* Font Definitions */ -@font-face - {font-family:Tahoma; - panose-1:2 11 6 4 3 5 4 4 2 4; - mso-font-charset:0; - mso-generic-font-family:swiss; - mso-font-pitch:variable; - mso-font-signature:553679495 -2147483648 8 0 66047 0;} - /* Style Definitions */ -p.MsoNormal, li.MsoNormal, div.MsoNormal - {mso-style-parent:&quot;&quot;; - margin:0in; - margin-bottom:.0001pt; - mso-pagination:widow-orphan; - font-size:12.0pt; - font-family:&quot;Times New Roman&quot;; - mso-fareast-font-family:&quot;Times New Roman&quot;;} -p - {margin-right:0in; - mso-margin-top-alt:auto; - mso-margin-bottom-alt:auto; - margin-left:0in; - mso-pagination:widow-orphan; - font-size:12.0pt; - font-family:&quot;Times New Roman&quot;; - mso-fareast-font-family:&quot;Times New Roman&quot;;} -p.BalloonText, li.BalloonText, div.BalloonText - {mso-style-name:&quot;Balloon Text&quot;; - margin:0in; - margin-bottom:.0001pt; - mso-pagination:widow-orphan; - font-size:8.0pt; - font-family:Tahoma; - mso-fareast-font-family:&quot;Times New Roman&quot;;} -@page Section1 - {size:8.5in 11.0in; - margin:1.0in 1.25in 1.0in 1.25in; - mso-header-margin:.5in; - mso-footer-margin:.5in; - mso-paper-source:0;} -div.Section1 - {page:Section1;} ---&gt; -&lt;/style&gt; -&lt;/head&gt; - -&lt;body lang=EN-US style=&apos;tab-interval:.5in&apos;&gt; - -&lt;div class=Section1&gt; - -&lt;p align=center style=&apos;text-align:center&apos;&gt;&lt;b&gt;Eclipse Public License - v 1.0&lt;/b&gt; -&lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&amp;quot;AGREEMENT&amp;quot;). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT&apos;S ACCEPTANCE -OF THIS AGREEMENT.&lt;/span&gt; &lt;/p&gt; - -&lt;p&gt;&lt;b&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;1. DEFINITIONS&lt;/span&gt;&lt;/b&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;&amp;quot;Contribution&amp;quot; means:&lt;/span&gt; &lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and&lt;br clear=left&gt; -b) in the case of each subsequent Contributor:&lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;i) -changes to the Program, and&lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;ii) -additions to the Program;&lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;where -such changes and/or additions to the Program originate from and are distributed -by that particular Contributor. A Contribution &apos;originates&apos; from a Contributor -if it was added to the Program by such Contributor itself or anyone acting on -such Contributor&apos;s behalf. Contributions do not include additions to the -Program which: (i) are separate modules of software distributed in conjunction -with the Program under their own license agreement, and (ii) are not derivative -works of the Program. &lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;&amp;quot;Contributor&amp;quot; means any person or -entity that distributes the Program.&lt;/span&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;&amp;quot;Licensed Patents &amp;quot; mean patent -claims licensable by a Contributor which are necessarily infringed by the use -or sale of its Contribution alone or when combined with the Program. &lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;&amp;quot;Program&amp;quot; means the Contributions -distributed in accordance with this Agreement.&lt;/span&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;&amp;quot;Recipient&amp;quot; means anyone who -receives the Program under this Agreement, including all Contributors.&lt;/span&gt; &lt;/p&gt; - -&lt;p&gt;&lt;b&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;2. GRANT OF RIGHTS&lt;/span&gt;&lt;/b&gt; &lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to&lt;span -style=&apos;color:red&apos;&gt; &lt;/span&gt;reproduce, prepare derivative works of, publicly -display, publicly perform, distribute and sublicense the Contribution of such -Contributor, if any, and such derivative works, in source code and object code -form.&lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide,&lt;span style=&apos;color:green&apos;&gt; &lt;/span&gt;royalty-free -patent license under Licensed Patents to make, use, sell, offer to sell, import -and otherwise transfer the Contribution of such Contributor, if any, in source -code and object code form. This patent license shall apply to the combination -of the Contribution and the Program if, at the time the Contribution is added -by the Contributor, such addition of the Contribution causes such combination -to be covered by the Licensed Patents. The patent license shall not apply to -any other combinations which include the Contribution. No hardware per se is -licensed hereunder. &lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;c) -Recipient understands that although each Contributor grants the licenses to its -Contributions set forth herein, no assurances are provided by any Contributor -that the Program does not infringe the patent or other intellectual property -rights of any other entity. Each Contributor disclaims any liability to Recipient -for claims brought by any other entity based on infringement of intellectual -property rights or otherwise. As a condition to exercising the rights and -licenses granted hereunder, each Recipient hereby assumes sole responsibility -to secure any other intellectual property rights needed, if any. For example, -if a third party patent license is required to allow Recipient to distribute -the Program, it is Recipient&apos;s responsibility to acquire that license before -distributing the Program.&lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;d) -Each Contributor represents that to its knowledge it has sufficient copyright -rights in its Contribution, if any, to grant the copyright license set forth in -this Agreement. &lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;b&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;3. REQUIREMENTS&lt;/span&gt;&lt;/b&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that:&lt;/span&gt; -&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;a) -it complies with the terms and conditions of this Agreement; and&lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;b) -its license agreement:&lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;i) -effectively disclaims on behalf of all Contributors all warranties and -conditions, express and implied, including warranties or conditions of title -and non-infringement, and implied warranties or conditions of merchantability -and fitness for a particular purpose; &lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits; &lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and&lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;iv) -states that source code for the Program is available from such Contributor, and -informs licensees how to obtain it in a reasonable manner on or through a -medium customarily used for software exchange.&lt;span style=&apos;color:blue&apos;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;When the Program is made available in source -code form:&lt;/span&gt; &lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;a) -it must be made available under this Agreement; and &lt;/span&gt;&lt;/p&gt; - -&lt;p class=MsoNormal style=&apos;margin-left:.5in&apos;&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;b) a -copy of this Agreement must be included with each copy of the Program. &lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;Contributors may not remove or alter any -copyright notices contained within the Program. &lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;Each Contributor must identify itself as the -originator of its Contribution, if any, in a manner that reasonably allows -subsequent Recipients to identify the originator of the Contribution. &lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;b&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;4. COMMERCIAL DISTRIBUTION&lt;/span&gt;&lt;/b&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;Commercial distributors of software may -accept certain responsibilities with respect to end users, business partners -and the like. While this license is intended to facilitate the commercial use -of the Program, the Contributor who includes the Program in a commercial -product offering should do so in a manner which does not create potential -liability for other Contributors. Therefore, if a Contributor includes the -Program in a commercial product offering, such Contributor (&amp;quot;Commercial -Contributor&amp;quot;) hereby agrees to defend and indemnify every other -Contributor (&amp;quot;Indemnified Contributor&amp;quot;) against any losses, damages and -costs (collectively &amp;quot;Losses&amp;quot;) arising from claims, lawsuits and other -legal actions brought by a third party against the Indemnified Contributor to -the extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor -to control, and cooperate with the Commercial Contributor in, the defense and -any related settlement negotiations. The Indemnified Contributor may participate -in any such claim at its own expense.&lt;/span&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;For example, a Contributor might include the -Program in a commercial product offering, Product X. That Contributor is then a -Commercial Contributor. If that Commercial Contributor then makes performance -claims, or offers warranties related to Product X, those performance claims and -warranties are such Commercial Contributor&apos;s responsibility alone. Under this -section, the Commercial Contributor would have to defend claims against the -other Contributors related to those performance claims and warranties, and if a -court requires any other Contributor to pay any damages as a result, the -Commercial Contributor must pay those damages.&lt;/span&gt; &lt;/p&gt; - -&lt;p&gt;&lt;b&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;5. NO WARRANTY&lt;/span&gt;&lt;/b&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN &amp;quot;AS IS&amp;quot; BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, -WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, -MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely -responsible for determining the appropriateness of using and distributing the -Program and assumes all risks associated with its exercise of rights under this -Agreement , including but not limited to the risks and costs of program errors, -compliance with applicable laws, damage to or loss of data, programs or -equipment, and unavailability or interruption of operations. &lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;b&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;6. DISCLAIMER OF LIABILITY&lt;/span&gt;&lt;/b&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF -THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGES.&lt;/span&gt; &lt;/p&gt; - -&lt;p&gt;&lt;b&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;7. GENERAL&lt;/span&gt;&lt;/b&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;If any provision of this Agreement is invalid -or unenforceable under applicable law, it shall not affect the validity or -enforceability of the remainder of the terms of this Agreement, and without -further action by the parties hereto, such provision shall be reformed to the -minimum extent necessary to make such provision valid and enforceable.&lt;/span&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;If Recipient institutes patent litigation -against any entity (including a cross-claim or counterclaim in a lawsuit) -alleging that the Program itself (excluding combinations of the Program with -other software or hardware) infringes such Recipient&apos;s patent(s), then such -Recipient&apos;s rights granted under Section 2(b) shall terminate as of the date -such litigation is filed. &lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;All Recipient&apos;s rights under this Agreement -shall terminate if it fails to comply with any of the material terms or -conditions of this Agreement and does not cure such failure in a reasonable -period of time after becoming aware of such noncompliance. If all Recipient&apos;s -rights under this Agreement terminate, Recipient agrees to cease use and -distribution of the Program as soon as reasonably practicable. However, -Recipient&apos;s obligations under this Agreement and any licenses granted by -Recipient relating to the Program shall continue and survive. &lt;/span&gt;&lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;Everyone is permitted to copy and distribute -copies of this Agreement, but in order to avoid inconsistency the Agreement is -copyrighted and may only be modified in the following manner. The Agreement -Steward reserves the right to publish new versions (including revisions) of -this Agreement from time to time. No one other than the Agreement Steward has -the right to modify this Agreement. The Eclipse Foundation is the initial -Agreement Steward. The Eclipse Foundation may assign the responsibility to -serve as the Agreement Steward to a suitable separate entity. Each new version -of the Agreement will be given a distinguishing version number. The Program -(including Contributions) may always be distributed subject to the version of -the Agreement under which it was received. In addition, after a new version of -the Agreement is published, Contributor may elect to distribute the Program -(including its Contributions) under the new version. Except as expressly stated -in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to -the intellectual property of any Contributor under this Agreement, whether -expressly, by implication, estoppel or otherwise. All rights in the Program not -expressly granted under this Agreement are reserved.&lt;/span&gt; &lt;/p&gt; - -&lt;p&gt;&lt;span style=&apos;font-size:10.0pt&apos;&gt;This Agreement is governed by the laws of the -State of New York and the intellectual property laws of the United States of -America. No party to this Agreement will bring a legal action under this -Agreement more than one year after the cause of action arose. Each party waives -its rights to a jury trial in any resulting litigation.&lt;/span&gt; &lt;/p&gt; - -&lt;p class=MsoNormal&gt;&lt;![if !supportEmptyParas]&gt;&amp;nbsp;&lt;![endif]&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; - -&lt;/div&gt; - -&lt;/body&gt; - -&lt;/html&gt; + Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT&apos;S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +&quot;Contribution&quot; means: + +a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution &apos;originates&apos; from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor&apos;s behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. + +&quot;Contributor&quot; means any person or entity that distributes the Program. + +&quot;Licensed Patents&quot; mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. + +&quot;Program&quot; means the Contributions distributed in accordance with this Agreement. + +&quot;Recipient&quot; means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient&apos;s responsibility to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the Program. + +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor (&quot;Commercial Contributor&quot;) hereby agrees to defend and indemnify every other Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor&apos;s responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient&apos;s patent(s), then such Recipient&apos;s rights granted under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient&apos;s rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient&apos;s rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient&apos;s obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. </license> <requires> - <import plugin="at.ac.tuwien.inso.eclipse.i18n" version="0.0.1" match="greaterOrEqual"/> + <import plugin="org.eclipselabs.tapiji.tools.core" version="0.0.1" match="greaterOrEqual"/> <import plugin="org.eclipse.core.resources" version="3.6.0" match="greaterOrEqual"/> <import plugin="org.eclipse.jface"/> - <import plugin="at.ac.tuwien.inso.eclipse.rbe" version="0.0.1" match="greaterOrEqual"/> + <import plugin="org.eclipselabs.tapiji.translator.rbe" version="0.0.1" match="greaterOrEqual"/> <import plugin="org.eclipse.jface.text"/> <import plugin="org.eclipse.jdt.core" version="3.6.0" match="greaterOrEqual"/> <import plugin="org.eclipse.jdt.ui" version="3.6.0" match="greaterOrEqual"/> @@ -368,10 +127,10 @@ its rights to a jury trial in any resulting litigation.&lt;/span&gt; &lt;/p&gt; </requires> <plugin - id="at.ac.tuwien.inso.eclipse.i18n.jsf" + id="org.eclipselabs.tapiji.tools.jsf" download-size="0" install-size="0" - version="0.0.1.qualifier" + version="0.0.0" unpack="false"/> </feature>
4558ca5a79a5106287438df8a737e4a1635e4534
hbase
HBASE-8383 Support lib/*jar inside coprocessor- jar--git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1471754 13f79535-47bb-0310-9956-ffa450edef68-
a
https://github.com/apache/hbase
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassLoaderBase.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassLoaderBase.java index 00a0f8e08cfa..0c470ad68484 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassLoaderBase.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassLoaderBase.java @@ -51,7 +51,6 @@ public class ClassLoaderBase extends URLClassLoader { * Creates a DynamicClassLoader that can load classes dynamically * from jar files under a specific folder. * - * @param conf the configuration for the cluster. * @param parent the parent ClassLoader to set. */ public ClassLoaderBase(final ClassLoader parent) { diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java index 971f4eff8596..c8ebae9ad0c3 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CoprocessorClassLoader.java @@ -158,7 +158,7 @@ private void init(Path path, String pathPrefix, Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); - if (entry.getName().matches("/lib/[^/]+\\.jar")) { + if (entry.getName().matches("[/]?lib/[^/]+\\.jar")) { File file = new File(parentDir, "." + pathPrefix + "." + path.getName() + "." + System.currentTimeMillis() + "." + entry.getName().substring(5)); IOUtils.copyBytes(jarFile.getInputStream(entry), new FileOutputStream(file), conf, true); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java index 2eb3300f54db..b6b92c35e84b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java @@ -382,6 +382,15 @@ public void testHBase3810() throws Exception { @Test public void testClassLoadingFromLibDirInJar() throws Exception { + loadingClassFromLibDirInJar("/lib/"); + } + + @Test + public void testClassLoadingFromRelativeLibDirInJar() throws Exception { + loadingClassFromLibDirInJar("lib/"); + } + + void loadingClassFromLibDirInJar(String libPrefix) throws Exception { FileSystem fs = cluster.getFileSystem(); File innerJarFile1 = buildCoprocessorJar(cpName1); @@ -397,7 +406,7 @@ public void testClassLoadingFromLibDirInJar() throws Exception { for (File jarFile: new File[] { innerJarFile1, innerJarFile2 }) { // Add archive entry - JarEntry jarAdd = new JarEntry("/lib/" + jarFile.getName()); + JarEntry jarAdd = new JarEntry(libPrefix + jarFile.getName()); jarAdd.setTime(jarFile.lastModified()); out.putNextEntry(jarAdd);
a0daab1afdab6266b59424efa079931623e2d5bf
orientdb
Fixed bugs on index where internal records were- not deleted--
c
https://github.com/orientechnologies/orientdb
diff --git a/commons/src/main/java/com/orientechnologies/common/collection/AbstractEntryIterator.java b/commons/src/main/java/com/orientechnologies/common/collection/AbstractEntryIterator.java index 53c02178eb8..4ec332fb673 100644 --- a/commons/src/main/java/com/orientechnologies/common/collection/AbstractEntryIterator.java +++ b/commons/src/main/java/com/orientechnologies/common/collection/AbstractEntryIterator.java @@ -58,8 +58,8 @@ final OMVRBTreeEntry<K, V> nextEntry() { next = OMVRBTree.successor(next); tree.pageIndex = 0; - lastReturned = next; } + lastReturned = next; return next; } @@ -78,9 +78,9 @@ final OMVRBTreeEntry<K, V> prevEntry() { next = OMVRBTree.predecessor(e); tree.pageIndex = next.getSize() - 1; - lastReturned = e; } + lastReturned = e; return e; } @@ -92,7 +92,7 @@ public void remove() { // deleted entries are replaced by their successors if (lastReturned.getLeft() != null && lastReturned.getRight() != null) next = lastReturned; - tree.deleteEntry(lastReturned); + next = tree.deleteEntry(lastReturned); expectedModCount = tree.modCount; lastReturned = null; } diff --git a/commons/src/main/java/com/orientechnologies/common/collection/OMVRBTree.java b/commons/src/main/java/com/orientechnologies/common/collection/OMVRBTree.java index 8d3cb611280..4561da2d673 100644 --- a/commons/src/main/java/com/orientechnologies/common/collection/OMVRBTree.java +++ b/commons/src/main/java/com/orientechnologies/common/collection/OMVRBTree.java @@ -2377,8 +2377,9 @@ private void insert_case5(final OMVRBTreeEntry<K, V> n) { * * @param p * node to delete + * @return */ - void deleteEntry(OMVRBTreeEntry<K, V> p) { + OMVRBTreeEntry<K, V> deleteEntry(OMVRBTreeEntry<K, V> p) { setSize(size() - 1); if (listener != null) @@ -2389,11 +2390,15 @@ void deleteEntry(OMVRBTreeEntry<K, V> p) { p.remove(); if (p.getSize() > 0) - return; + return p; } + final OMVRBTreeEntry<K, V> next = successor(p); // DELETE THE ENTIRE NODE, RE-BUILDING THE STRUCTURE removeNode(p); + + // RETURN NEXT NODE + return next; } /** diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/OMemoryStream.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/OMemoryStream.java index d741d60d6eb..4703da14f06 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/OMemoryStream.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/OMemoryStream.java @@ -29,11 +29,12 @@ * */ public class OMemoryStream extends OutputStream { + public static final int DEF_SIZE = 1024; + private byte[] buffer; private int position; private static final int NATIVE_COPY_THRESHOLD = 9; - private static final int DEF_SIZE = 1024; // private int fixedSize = 0; @@ -74,6 +75,7 @@ public void copyFrom(final OMemoryStream iSource, final int iSize) { if (iSize < 0) return; + assureSpaceFor(position + iSize); System.arraycopy(iSource.buffer, iSource.position, buffer, position, iSize); } @@ -245,7 +247,7 @@ private void assureSpaceFor(final int iLength) { final int bufferLength = localBuffer.length; - if (bufferLength <= capacity) { + if (bufferLength < capacity) { OProfiler.getInstance().updateCounter("OMemOutStream.resize", +1); final byte[] newbuf = new byte[Math.max(bufferLength << 1, capacity)]; diff --git a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java index b1a8329e416..88f28193781 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/serialization/serializer/record/string/ORecordSerializerCSVAbstract.java @@ -700,7 +700,7 @@ private static OIdentifiable linkToStream(final StringBuilder buffer, final ORec // JUST THE REFERENCE rid = (ORID) iLinked; - if (rid.isNew()) { + if (rid.isValid() && rid.isNew()) { // SAVE AT THE FLY AND STORE THE NEW RID final ORecord<?> record = rid.getRecord(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java b/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java index cc2dc8d125a..4c208d0e52c 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java +++ b/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeEntryPersistent.java @@ -139,7 +139,7 @@ public OMVRBTreeEntryPersistent(final OMVRBTreeEntry<K, V> iParent, final int iP markDirty(); } - public OMVRBTreeEntryDataProvider<K, V> getDataEntry() { + public OMVRBTreeEntryDataProvider<K, V> getProvider() { return dataProvider; } @@ -240,20 +240,22 @@ protected void updateRefsAfterCreation() { * @throws IOException */ public OMVRBTreeEntryPersistent<K, V> delete() throws IOException { - pTree.removeNodeFromMemory(this); - pTree.removeEntry(dataProvider.getIdentity()); + if (dataProvider != null) { + pTree.removeNodeFromMemory(this); + pTree.removeEntry(dataProvider.getIdentity()); - // EARLY LOAD LEFT AND DELETE IT RECURSIVELY - if (getLeft() != null) - ((OMVRBTreeEntryPersistent<K, V>) getLeft()).delete(); + // EARLY LOAD LEFT AND DELETE IT RECURSIVELY + if (getLeft() != null) + ((OMVRBTreeEntryPersistent<K, V>) getLeft()).delete(); - // EARLY LOAD RIGHT AND DELETE IT RECURSIVELY - if (getRight() != null) - ((OMVRBTreeEntryPersistent<K, V>) getRight()).delete(); + // EARLY LOAD RIGHT AND DELETE IT RECURSIVELY + if (getRight() != null) + ((OMVRBTreeEntryPersistent<K, V>) getRight()).delete(); - // DELETE MYSELF - dataProvider.delete(); - clear(); + // DELETE MYSELF + dataProvider.delete(); + clear(); + } return this; } @@ -535,7 +537,7 @@ protected void remove() { if (dataProvider.removeAt(index)) markDirty(); - tree.setPageIndex(0); + tree.setPageIndex(index - 1); if (index == 0) pTree.updateEntryPoint(oldKey, this); diff --git a/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreePersistent.java b/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreePersistent.java index 7c125093dff..2f49542599c 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreePersistent.java +++ b/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreePersistent.java @@ -31,6 +31,7 @@ import com.orientechnologies.common.log.OLogManager; import com.orientechnologies.common.profiler.OProfiler; import com.orientechnologies.orient.core.config.OGlobalConfiguration; +import com.orientechnologies.orient.core.exception.ORecordNotFoundException; import com.orientechnologies.orient.core.exception.OStorageException; import com.orientechnologies.orient.core.id.ORID; import com.orientechnologies.orient.core.memory.OLowMemoryException; @@ -114,7 +115,7 @@ public OMVRBTreePersistent<K, V> save() throws IOException { protected void saveTreeNode() throws IOException { if (root != null) { OMVRBTreeEntryPersistent<K, V> pRoot = (OMVRBTreeEntryPersistent<K, V>) root; - if (pRoot.getDataEntry().getIdentity().isNew()) { + if (pRoot.getProvider().getIdentity().isNew()) { // FIRST TIME: SAVE IT pRoot.save(); } @@ -189,7 +190,10 @@ public void clear() { try { recordsToCommit.clear(); if (root != null) { - ((OMVRBTreeEntryPersistent<K, V>) root).delete(); + try { + ((OMVRBTreeEntryPersistent<K, V>) root).delete(); + } catch (ORecordNotFoundException e) { + } super.clear(); markDirty(); save(); @@ -835,6 +839,7 @@ protected void rotateRight(final OMVRBTreeEntry<K, V> p) { @Override protected void removeNode(final OMVRBTreeEntry<K, V> p) { removeNodeFromMemory((OMVRBTreeEntryPersistent<K, V>) p); + ((OMVRBTreeEntryPersistent<K, V>) p).getProvider().delete(); super.removeNode(p); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeRID.java b/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeRID.java index a3c4eb7bf6a..1998c809c54 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeRID.java +++ b/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeRID.java @@ -42,6 +42,7 @@ public OMVRBTreeRID() { public OMVRBTreeRID(final ORID iRID) { this(new OMVRBTreeRIDProvider(null, iRID.getClusterId(), iRID)); + load(); } public OMVRBTreeRID(final String iClusterName) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeRIDSet.java b/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeRIDSet.java index ef81bc20de0..9e9689948af 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeRIDSet.java +++ b/core/src/main/java/com/orientechnologies/orient/core/type/tree/OMVRBTreeRIDSet.java @@ -137,6 +137,7 @@ public void save() throws IOException { } public ODocument toDocument() { + tree.lazySave(); return ((OMVRBTreeRIDProvider) tree.getProvider()).toDocument(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeEntryDataProviderAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeEntryDataProviderAbstract.java index f92ed3c02d8..d02516b795e 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeEntryDataProviderAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeEntryDataProviderAbstract.java @@ -39,11 +39,12 @@ public abstract class OMVRBTreeEntryDataProviderAbstract<K, V> implements OMVRBT protected ORecordId rightRid; protected boolean color = OMVRBTree.RED; protected ORecordBytesLazy record; - protected OMemoryStream stream = new OMemoryStream(); + protected OMemoryStream stream; - public OMVRBTreeEntryDataProviderAbstract(final OMVRBTreeProviderAbstract<K, V> iTreeDataProvider) { + public OMVRBTreeEntryDataProviderAbstract(final OMVRBTreeProviderAbstract<K, V> iTreeDataProvider, final int iFixedSize) { this(iTreeDataProvider, null); pageSize = treeDataProvider.getDefaultPageSize(); + stream = new OMemoryStream(iFixedSize); } public OMVRBTreeEntryDataProviderAbstract(final OMVRBTreeProviderAbstract<K, V> iTreeDataProvider, final ORID iRID) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeMapEntryProvider.java b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeMapEntryProvider.java index 7b075da0b07..37f1e976772 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeMapEntryProvider.java +++ b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeMapEntryProvider.java @@ -36,7 +36,7 @@ public class OMVRBTreeMapEntryProvider<K, V> extends OMVRBTreeEntryDataProviderA @SuppressWarnings("unchecked") public OMVRBTreeMapEntryProvider(final OMVRBTreeMapProvider<K, V> iTreeDataProvider) { - super(iTreeDataProvider); + super(iTreeDataProvider, OMemoryStream.DEF_SIZE); keys = (K[]) new Object[pageSize]; values = (V[]) new Object[pageSize]; serializedKeys = new int[pageSize]; @@ -199,7 +199,10 @@ public void clear() { public OSerializableStream fromStream(final byte[] iStream) throws OSerializationException { final long timer = OProfiler.getInstance().startChrono(); - stream.setSource(iStream); + if (stream == null) + stream = new OMemoryStream(iStream); + else + stream.setSource(iStream); try { pageSize = stream.getAsInteger(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeProvider.java b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeProvider.java index 1b90c50db65..0ae061e25d2 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeProvider.java +++ b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeProvider.java @@ -35,10 +35,10 @@ public interface OMVRBTreeProvider<K, V> { public ORID getRoot(); - public boolean setSize(int iSize); - public boolean setRoot(ORID iRid); + public boolean setSize(int iSize); + /** Give a chance to update config parameters (defaultSizePage, ...) */ public boolean updateConfig(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeRIDEntryProvider.java b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeRIDEntryProvider.java index 87da12afb56..6fc516f6af8 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeRIDEntryProvider.java +++ b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeRIDEntryProvider.java @@ -53,7 +53,7 @@ public class OMVRBTreeRIDEntryProvider extends OMVRBTreeEntryDataProviderAbstrac protected final static int OFFSET_RIDLIST = OFFSET_RIGHT + ORecordId.PERSISTENT_SIZE; public OMVRBTreeRIDEntryProvider(final OMVRBTreeRIDProvider iTreeDataProvider) { - super(iTreeDataProvider); + super(iTreeDataProvider, OFFSET_RIDLIST + (iTreeDataProvider.getDefaultPageSize() * ORecordId.PERSISTENT_SIZE)); } public OMVRBTreeRIDEntryProvider(final OMVRBTreeRIDProvider iTreeDataProvider, final ORID iRID) { @@ -101,16 +101,14 @@ public boolean removeAt(final int iIndex) { return setDirty(); } - public boolean copyDataFrom(final OMVRBTreeEntryDataProvider<OIdentifiable, OIdentifiable> iFrom, int iStartPosition) { - OMVRBTreeRIDEntryProvider parent = (OMVRBTreeRIDEntryProvider) iFrom; + public boolean copyDataFrom(final OMVRBTreeEntryDataProvider<OIdentifiable, OIdentifiable> iFrom, final int iStartPosition) { size = iFrom.getSize() - iStartPosition; - stream.jump(0).copyFrom(parent.moveToIndex(iStartPosition), size); - stream.setSource(parent.stream.copy()); + moveToIndex(0).copyFrom(((OMVRBTreeRIDEntryProvider) iFrom).moveToIndex(iStartPosition), size * ORecordId.PERSISTENT_SIZE); return setDirty(); } public boolean truncate(final int iNewSize) { - stream.jump(iNewSize).fill(size - iNewSize, (byte) 0); + moveToIndex(iNewSize).fill((size - iNewSize) * ORecordId.PERSISTENT_SIZE, (byte) 0); size = iNewSize; return setDirty(); } @@ -125,7 +123,10 @@ public boolean copyFrom(final OMVRBTreeEntryDataProvider<OIdentifiable, OIdentif } public OSerializableStream fromStream(final byte[] iStream) throws OSerializationException { - stream.setSource(iStream); + if (stream == null) + stream = new OMemoryStream(iStream); + else + stream.setSource(iStream); size = stream.jump(OFFSET_NODESIZE).getAsInteger(); color = stream.jump(OFFSET_COLOR).getAsBoolean(); @@ -148,7 +149,7 @@ public byte[] toStream() throws OSerializationException { } // RETURN DIRECTLY THE UNDERLYING BUFFER SINCE IT'S FIXED - final byte[] buffer = stream.toByteArray(); + final byte[] buffer = stream.getInternalBuffer(); record.fromStream(buffer); return buffer; } diff --git a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeRIDProvider.java b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeRIDProvider.java index 369ff25aae5..1b6c167a327 100644 --- a/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeRIDProvider.java +++ b/core/src/main/java/com/orientechnologies/orient/core/type/tree/provider/OMVRBTreeRIDProvider.java @@ -29,6 +29,7 @@ import com.orientechnologies.orient.core.serialization.OSerializableStream; import com.orientechnologies.orient.core.serialization.serializer.string.OStringBuilderSerializable; import com.orientechnologies.orient.core.storage.OStorage; +import com.orientechnologies.orient.core.type.tree.OMVRBTreePersistent; /** * MVRB-Tree implementation to handle a set of RID. @@ -37,22 +38,20 @@ */ public class OMVRBTreeRIDProvider extends OMVRBTreeProviderAbstract<OIdentifiable, OIdentifiable> implements OStringBuilderSerializable { - private static final long serialVersionUID = 1L; - private static final int PROTOCOL_VERSION = 0; + private static final long serialVersionUID = 1L; + private static final int PROTOCOL_VERSION = 0; - private OMVRBTree<OIdentifiable, OIdentifiable> tree; - private boolean embeddedStreaming = true; + private OMVRBTreePersistent<OIdentifiable, OIdentifiable> tree; + private boolean embeddedStreaming = true; public OMVRBTreeRIDProvider(final OStorage iStorage, final int iClusterId, final ORID iRID) { this(iStorage, getDatabase().getClusterNameById(iClusterId)); record.setIdentity(iRID.getClusterId(), iRID.getClusterPosition()); - load(); } public OMVRBTreeRIDProvider(final OStorage iStorage, final String iClusterName, final ORID iRID) { this(iStorage, iClusterName); record.setIdentity(iRID.getClusterId(), iRID.getClusterPosition()); - load(); } public OMVRBTreeRIDProvider(final OStorage iStorage, final int iClusterId) { @@ -126,7 +125,7 @@ public OMVRBTree<OIdentifiable, OIdentifiable> getTree() { return tree; } - public void setTree(OMVRBTree<OIdentifiable, OIdentifiable> tree) { + public void setTree(final OMVRBTreePersistent<OIdentifiable, OIdentifiable> tree) { this.tree = tree; } diff --git a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/ONetworkProtocolBinary.java b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/ONetworkProtocolBinary.java index b2bafcfc634..7da0d62ee3f 100644 --- a/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/ONetworkProtocolBinary.java +++ b/server/src/main/java/com/orientechnologies/orient/server/network/protocol/binary/ONetworkProtocolBinary.java @@ -871,9 +871,11 @@ else if (iLinked instanceof Map<?, ?>) } protected int deleteRecord(final ORID rid, final int version) { - ORecordInternal<?> record = connection.database.load(rid); - record.setVersion(version); - record.delete(); + final ORecordInternal<?> record = connection.database.load(rid); + if (record != null) { + record.setVersion(version); + record.delete(); + } return 1; } diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/OMVRBTreeTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/OMVRBTreeTest.java index f998fd8529a..295366fc265 100644 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/OMVRBTreeTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/OMVRBTreeTest.java @@ -15,6 +15,8 @@ */ package com.orientechnologies.orient.test.database.auto; +import java.util.Iterator; + import org.testng.Assert; import org.testng.annotations.Parameters; import org.testng.annotations.Test; @@ -22,6 +24,7 @@ import com.orientechnologies.orient.core.db.document.ODatabaseDocument; import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import com.orientechnologies.orient.core.db.record.OIdentifiable; +import com.orientechnologies.orient.core.id.ORID; import com.orientechnologies.orient.core.id.ORecordId; import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.type.tree.OMVRBTreeRIDSet; @@ -48,23 +51,45 @@ public OMVRBTreeTest(String iURL) { @Test public void treeSet() { database.open("admin", "admin"); + int total = 1000; OMVRBTreeRIDSet set = new OMVRBTreeRIDSet("index"); - for (int i = 0; i < 10000; ++i) + for (int i = 0; i < total; ++i) set.add(new ORecordId(10, i)); - Assert.assertEquals(set.size(), 10000); + Assert.assertEquals(set.size(), total); ODocument doc = set.toDocument(); doc.save(); database.close(); database.open("admin", "admin"); - OMVRBTreeRIDSet set2 = new OMVRBTreeRIDSet(doc.getIdentity()); - Assert.assertEquals(set2.size(), 10000); + OMVRBTreeRIDSet set2 = new OMVRBTreeRIDSet(doc.getIdentity()).setAutoConvert(false); + Assert.assertEquals(set2.size(), total); + // ITERABLE int i = 0; - for (OIdentifiable rid : set2) - Assert.assertEquals(rid.getIdentity().getClusterPosition(), i++); + for (OIdentifiable rid : set2) { + Assert.assertEquals(rid.getIdentity().getClusterPosition(), i); + // System.out.println("Adding " + rid); + i++; + } + Assert.assertEquals(i, total); + + ORID rootRID = doc.field("root", ORecordId.class); + + // ITERATOR REMOVE + i = 0; + for (Iterator<OIdentifiable> it = set2.iterator(); it.hasNext();) { + final OIdentifiable rid = it.next(); + Assert.assertEquals(rid.getIdentity().getClusterPosition(), i); + // System.out.println("Removing " + rid); + it.remove(); + i++; + } + Assert.assertEquals(i, total); + Assert.assertEquals(set2.size(), 0); + + //Assert.assertNull(database.load(rootRID)); database.close(); }
4145b9f00c83828c55ade3b509a7dce1ab621101
camel
CAMEL-3796 Polish the- CxfRsProducerAddressOverrideTest--git-svn-id: https://svn.apache.org/repos/asf/camel/trunk@1084067 13f79535-47bb-0310-9956-ffa450edef68-
p
https://github.com/apache/camel
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerAddressOverrideTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerAddressOverrideTest.java index 2ad191fcf6d6b..84be7fb3fbcbf 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerAddressOverrideTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerAddressOverrideTest.java @@ -16,15 +16,8 @@ */ package org.apache.camel.component.cxf.jaxrs; -import java.util.List; - import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; import org.apache.camel.Message; -import org.apache.camel.Processor; -import org.apache.camel.component.cxf.CxfConstants; -import org.apache.camel.component.cxf.jaxrs.testbean.Customer; -import org.junit.Test; import org.springframework.context.support.AbstractXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -34,97 +27,8 @@ protected AbstractXmlApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/jaxrs/CxfRsSpringProducerAddressOverride.xml"); } - @Override - public void testGetConstumerWithClientProxyAPI() { - // START SNIPPET: ProxyExample - Exchange exchange = template.send("direct://proxy", new Processor() { - - public void process(Exchange exchange) throws Exception { - exchange.setPattern(ExchangePattern.InOut); - Message inMessage = exchange.getIn(); - - inMessage.setHeader(Exchange.DESTINATION_OVERRIDE_URL, - "http://localhost:9002"); - - // set the operation name - inMessage.setHeader(CxfConstants.OPERATION_NAME, "getCustomer"); - // using the proxy client API - inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.FALSE); - // set the parameters , if you just have one parameter - // camel will put this object into an Object[] itself - inMessage.setBody("123"); - } - - }); - - // get the response message - Customer response = (Customer) exchange.getOut().getBody(); - - assertNotNull("The response should not be null ", response); - assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123"); - assertEquals("Get a wrong customer name", response.getName(), "John"); - // END SNIPPET: ProxyExample - } - - @Test - public void testGetConstumersWithClientProxyAPI() { - Exchange exchange = template.send("direct://proxy", new Processor() { - public void process(Exchange exchange) throws Exception { - exchange.setPattern(ExchangePattern.InOut); - Message inMessage = exchange.getIn(); - inMessage.setHeader(Exchange.DESTINATION_OVERRIDE_URL, - "http://localhost:9002"); - // set the operation name - inMessage.setHeader(CxfConstants.OPERATION_NAME, "getCustomers"); - // using the proxy client API - inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.FALSE); - // set the parameters , if you just have one parameter - // camel will put this object into an Object[] itself - inMessage.setBody(null); - } - }); - - // get the response message - List<Customer> response = (List<Customer>) exchange.getOut().getBody(); - - assertNotNull("The response should not be null ", response); - assertEquals("Get a wrong customer id ", String.valueOf(response.get(0).getId()), "113"); - assertEquals("Get a wrong customer name", response.get(0).getName(), "Dan"); + protected void setupDestinationURL(Message inMessage) { + inMessage.setHeader(Exchange.DESTINATION_OVERRIDE_URL, + "http://localhost:9002"); } - - @Override - public void testGetConstumerWithHttpCentralClientAPI() { - // START SNIPPET: HttpExample - Exchange exchange = template.send("direct://http", new Processor() { - - public void process(Exchange exchange) throws Exception { - exchange.setPattern(ExchangePattern.InOut); - Message inMessage = exchange.getIn(); - - inMessage.setHeader(Exchange.DESTINATION_OVERRIDE_URL, - "http://localhost:9002"); - - // using the http central client API - inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE); - // set the Http method - inMessage.setHeader(Exchange.HTTP_METHOD, "GET"); - // set the relative path - inMessage.setHeader(Exchange.HTTP_PATH, "/customerservice/customers/123"); - // Specify the response class , cxfrs will use InputStream as the response object type - inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_RESPONSE_CLASS, Customer.class); - // since we use the Get method, so we don't need to set the message body - inMessage.setBody(null); - } - - }); - - // get the response message - Customer response = (Customer) exchange.getOut().getBody(); - - assertNotNull("The response should not be null ", response); - assertEquals("Get a wrong customer id ", String.valueOf(response.getId()), "123"); - assertEquals("Get a wrong customer name", response.getName(), "John"); - // END SNIPPET: HttpExample - } - } diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java index 9ffe610d56e52..837e120c871f3 100644 --- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java +++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducerTest.java @@ -47,6 +47,10 @@ protected AbstractXmlApplicationContext createApplicationContext() { return new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/jaxrs/CxfRsSpringProducer.xml"); } + protected void setupDestinationURL(Message inMessage) { + // do nothing here + } + @Test public void testGetConstumerWithClientProxyAPI() { // START SNIPPET: ProxyExample @@ -54,6 +58,7 @@ public void testGetConstumerWithClientProxyAPI() { public void process(Exchange exchange) throws Exception { exchange.setPattern(ExchangePattern.InOut); Message inMessage = exchange.getIn(); + setupDestinationURL(inMessage); // set the operation name inMessage.setHeader(CxfConstants.OPERATION_NAME, "getCustomer"); // using the proxy client API @@ -79,6 +84,7 @@ public void testGetConstumersWithClientProxyAPI() { public void process(Exchange exchange) throws Exception { exchange.setPattern(ExchangePattern.InOut); Message inMessage = exchange.getIn(); + setupDestinationURL(inMessage); // set the operation name inMessage.setHeader(CxfConstants.OPERATION_NAME, "getCustomers"); // using the proxy client API @@ -104,6 +110,7 @@ public void testGetConstumerWithHttpCentralClientAPI() { public void process(Exchange exchange) throws Exception { exchange.setPattern(ExchangePattern.InOut); Message inMessage = exchange.getIn(); + setupDestinationURL(inMessage); // using the http central client API inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE); // set the Http method
992ba4c79ce11b0b72f9e15463a3b88505a41b88
hadoop
merge YARN-360 from trunk. Allow apps to- concurrently register tokens for renewal. Contributed by Daryn Sharp.--git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1442442 13f79535-47bb-0310-9956-ffa450edef68-
a
https://github.com/apache/hadoop
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 01f1bcbe45cc5..6c8f2e26bf5e1 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -90,6 +90,9 @@ Release 2.0.3-alpha - Unreleased YARN-277. Use AMRMClient in DistributedShell to exemplify the approach. (Bikas Saha via hitesh) + YARN-360. Allow apps to concurrently register tokens for renewal. + (Daryn Sharp via sseth) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml b/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml index 082df54630510..8526c9a737639 100644 --- a/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml +++ b/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml @@ -167,6 +167,11 @@ <Field name="minimumAllocation" /> <Bug pattern="IS2_INCONSISTENT_SYNC" /> </Match> + <Match> + <Class name="org.apache.hadoop.yarn.server.resourcemanager.security.DelegationTokenRenewer"/> + <Field name="renewalTimer" /> + <Bug code="IS"/> + </Match> <!-- Don't care if putIfAbsent value is ignored --> <Match> diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java index 9232190ba3bec..066a0a5b969d9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/security/DelegationTokenRenewer.java @@ -261,7 +261,7 @@ private void addTokenToList(DelegationTokenToRenew t) { * done else false. * @throws IOException */ - public synchronized void addApplication( + public void addApplication( ApplicationId applicationId, Credentials ts, boolean shouldCancelAtEnd) throws IOException { if (ts == null) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java index ad127a9264d9d..c59625361ca8c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/security/TestDelegationTokenRenewer.java @@ -21,11 +21,17 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.Collections; +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -50,6 +56,8 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; /** * unit test - @@ -541,4 +549,54 @@ public void testDTKeepAlive2() throws Exception { fail("Renewal of cancelled token should have failed"); } catch (InvalidToken ite) {} } + + @Test(timeout=2000) + public void testConncurrentAddApplication() + throws IOException, InterruptedException, BrokenBarrierException { + final CyclicBarrier startBarrier = new CyclicBarrier(2); + final CyclicBarrier endBarrier = new CyclicBarrier(2); + + // this token uses barriers to block during renew + final Credentials creds1 = new Credentials(); + final Token<?> token1 = mock(Token.class); + creds1.addToken(new Text("token"), token1); + doReturn(true).when(token1).isManaged(); + doAnswer(new Answer<Long>() { + public Long answer(InvocationOnMock invocation) + throws InterruptedException, BrokenBarrierException { + startBarrier.await(); + endBarrier.await(); + return Long.MAX_VALUE; + }}).when(token1).renew(any(Configuration.class)); + + // this dummy token fakes renewing + final Credentials creds2 = new Credentials(); + final Token<?> token2 = mock(Token.class); + creds2.addToken(new Text("token"), token2); + doReturn(true).when(token2).isManaged(); + doReturn(Long.MAX_VALUE).when(token2).renew(any(Configuration.class)); + + // fire up the renewer + final DelegationTokenRenewer dtr = new DelegationTokenRenewer(); + dtr.init(conf); + dtr.start(); + + // submit a job that blocks during renewal + Thread submitThread = new Thread() { + @Override + public void run() { + try { + dtr.addApplication(mock(ApplicationId.class), creds1, false); + } catch (IOException e) {} + } + }; + submitThread.start(); + + // wait till 1st submit blocks, then submit another + startBarrier.await(); + dtr.addApplication(mock(ApplicationId.class), creds2, false); + // signal 1st to complete + endBarrier.await(); + submitThread.join(); + } }
98249507cff3e363ecb4c5f06f14f0bb96da1ad5
elasticsearch
Add missing index name to indexing slow log--This was lost in refactoring even on the 2.x branch. The slow-log-is not per index not per shard anymore such that we don't add the-shard ID as the logger prefix. This commit adds back the index-name as part of the logging message not as a prefix on the logger-for better testabilitly.--Closes -17025-
c
https://github.com/elastic/elasticsearch
diff --git a/core/src/main/java/org/elasticsearch/index/IndexingSlowLog.java b/core/src/main/java/org/elasticsearch/index/IndexingSlowLog.java index 5452daa7f077e..75d3d60daad9d 100644 --- a/core/src/main/java/org/elasticsearch/index/IndexingSlowLog.java +++ b/core/src/main/java/org/elasticsearch/index/IndexingSlowLog.java @@ -36,6 +36,7 @@ /** */ public final class IndexingSlowLog implements IndexingOperationListener { + private final Index index; private boolean reformat; private long indexWarnThreshold; private long indexInfoThreshold; @@ -85,6 +86,7 @@ public final class IndexingSlowLog implements IndexingOperationListener { IndexingSlowLog(IndexSettings indexSettings, ESLogger indexLogger, ESLogger deleteLogger) { this.indexLogger = indexLogger; this.deleteLogger = deleteLogger; + this.index = indexSettings.getIndex(); indexSettings.getScopedSettings().addSettingsUpdateConsumer(INDEX_INDEXING_SLOWLOG_REFORMAT_SETTING, this::setReformat); this.reformat = indexSettings.getValue(INDEX_INDEXING_SLOWLOG_REFORMAT_SETTING); @@ -141,13 +143,13 @@ public void postIndex(Engine.Index index) { private void postIndexing(ParsedDocument doc, long tookInNanos) { if (indexWarnThreshold >= 0 && tookInNanos > indexWarnThreshold) { - indexLogger.warn("{}", new SlowLogParsedDocumentPrinter(doc, tookInNanos, reformat, maxSourceCharsToLog)); + indexLogger.warn("{}", new SlowLogParsedDocumentPrinter(index, doc, tookInNanos, reformat, maxSourceCharsToLog)); } else if (indexInfoThreshold >= 0 && tookInNanos > indexInfoThreshold) { - indexLogger.info("{}", new SlowLogParsedDocumentPrinter(doc, tookInNanos, reformat, maxSourceCharsToLog)); + indexLogger.info("{}", new SlowLogParsedDocumentPrinter(index, doc, tookInNanos, reformat, maxSourceCharsToLog)); } else if (indexDebugThreshold >= 0 && tookInNanos > indexDebugThreshold) { - indexLogger.debug("{}", new SlowLogParsedDocumentPrinter(doc, tookInNanos, reformat, maxSourceCharsToLog)); + indexLogger.debug("{}", new SlowLogParsedDocumentPrinter(index, doc, tookInNanos, reformat, maxSourceCharsToLog)); } else if (indexTraceThreshold >= 0 && tookInNanos > indexTraceThreshold) { - indexLogger.trace("{}", new SlowLogParsedDocumentPrinter(doc, tookInNanos, reformat, maxSourceCharsToLog)); + indexLogger.trace("{}", new SlowLogParsedDocumentPrinter(index, doc, tookInNanos, reformat, maxSourceCharsToLog)); } } @@ -156,9 +158,11 @@ static final class SlowLogParsedDocumentPrinter { private final long tookInNanos; private final boolean reformat; private final int maxSourceCharsToLog; + private final Index index; - SlowLogParsedDocumentPrinter(ParsedDocument doc, long tookInNanos, boolean reformat, int maxSourceCharsToLog) { + SlowLogParsedDocumentPrinter(Index index, ParsedDocument doc, long tookInNanos, boolean reformat, int maxSourceCharsToLog) { this.doc = doc; + this.index = index; this.tookInNanos = tookInNanos; this.reformat = reformat; this.maxSourceCharsToLog = maxSourceCharsToLog; @@ -167,6 +171,7 @@ static final class SlowLogParsedDocumentPrinter { @Override public String toString() { StringBuilder sb = new StringBuilder(); + sb.append(index).append(" "); sb.append("took[").append(TimeValue.timeValueNanos(tookInNanos)).append("], took_millis[").append(TimeUnit.NANOSECONDS.toMillis(tookInNanos)).append("], "); sb.append("type[").append(doc.type()).append("], "); sb.append("id[").append(doc.id()).append("], "); diff --git a/core/src/test/java/org/elasticsearch/index/IndexingSlowLogTests.java b/core/src/test/java/org/elasticsearch/index/IndexingSlowLogTests.java index e367636651125..9e05122322a90 100644 --- a/core/src/test/java/org/elasticsearch/index/IndexingSlowLogTests.java +++ b/core/src/test/java/org/elasticsearch/index/IndexingSlowLogTests.java @@ -36,24 +36,30 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.startsWith; public class IndexingSlowLogTests extends ESTestCase { public void testSlowLogParsedDocumentPrinterSourceToLog() throws IOException { BytesReference source = JsonXContent.contentBuilder().startObject().field("foo", "bar").endObject().bytes(); ParsedDocument pd = new ParsedDocument(new StringField("uid", "test:id", Store.YES), new LegacyIntField("version", 1, Store.YES), "id", "test", null, 0, -1, null, source, null); - + Index index = new Index("foo", "123"); // Turning off document logging doesn't log source[] - SlowLogParsedDocumentPrinter p = new SlowLogParsedDocumentPrinter(pd, 10, true, 0); + SlowLogParsedDocumentPrinter p = new SlowLogParsedDocumentPrinter(index, pd, 10, true, 0); assertThat(p.toString(), not(containsString("source["))); // Turning on document logging logs the whole thing - p = new SlowLogParsedDocumentPrinter(pd, 10, true, Integer.MAX_VALUE); + p = new SlowLogParsedDocumentPrinter(index, pd, 10, true, Integer.MAX_VALUE); assertThat(p.toString(), containsString("source[{\"foo\":\"bar\"}]")); // And you can truncate the source - p = new SlowLogParsedDocumentPrinter(pd, 10, true, 3); + p = new SlowLogParsedDocumentPrinter(index, pd, 10, true, 3); + assertThat(p.toString(), containsString("source[{\"f]")); + + // And you can truncate the source + p = new SlowLogParsedDocumentPrinter(index, pd, 10, true, 3); assertThat(p.toString(), containsString("source[{\"f]")); + assertThat(p.toString(), startsWith("[foo/123] took")); } public void testReformatSetting() {
296b6b2f5757d2f8100daef0d2507183deeca77a
elasticsearch
use custom similarity in search (if there is one)--
a
https://github.com/elastic/elasticsearch
diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/ExtendedIndexSearcher.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/ExtendedIndexSearcher.java new file mode 100644 index 0000000000000..960fcef9a5416 --- /dev/null +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/ExtendedIndexSearcher.java @@ -0,0 +1,69 @@ +/* + * Licensed to Elastic Search and Shay Banon under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. Elastic Search licenses this + * file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common.lucene.search; + +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.search.IndexSearcher; + +/** + * @author kimchy (shay.banon) + */ +public class ExtendedIndexSearcher extends IndexSearcher { + + public ExtendedIndexSearcher(IndexSearcher searcher) { + super(searcher.getIndexReader()); + setSimilarity(searcher.getSimilarity()); + } + + public ExtendedIndexSearcher(IndexReader r) { + super(r); + } + + public IndexReader[] subReaders() { + return this.subReaders; + } + + public int[] docStarts() { + return this.docStarts; + } + + // taken from DirectoryReader#readerIndex + + public int readerIndex(int doc) { + int lo = 0; // search starts array + int hi = subReaders.length - 1; // for first element less + + while (hi >= lo) { + int mid = (lo + hi) >>> 1; + int midValue = docStarts[mid]; + if (doc < midValue) + hi = mid - 1; + else if (doc > midValue) + lo = mid + 1; + else { // found a match + while (mid + 1 < subReaders.length && docStarts[mid + 1] == midValue) { + mid++; // scan to last match + } + return mid; + } + } + return hi; + } +} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java index 1be00f814eb03..d7dae6bfe068f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/ContextIndexSearcher.java @@ -19,10 +19,11 @@ package org.elasticsearch.search.internal; -import org.apache.lucene.index.IndexReader; import org.apache.lucene.search.*; import org.elasticsearch.common.collect.Lists; import org.elasticsearch.common.lucene.MultiCollector; +import org.elasticsearch.common.lucene.search.ExtendedIndexSearcher; +import org.elasticsearch.index.engine.Engine; import org.elasticsearch.search.dfs.CachedDfSource; import java.io.IOException; @@ -31,7 +32,7 @@ /** * @author kimchy (shay.banon) */ -public class ContextIndexSearcher extends IndexSearcher { +public class ContextIndexSearcher extends ExtendedIndexSearcher { private SearchContext searchContext; @@ -43,42 +44,11 @@ public class ContextIndexSearcher extends IndexSearcher { private boolean useGlobalCollectors = false; - public ContextIndexSearcher(SearchContext searchContext, IndexReader r) { - super(r); + public ContextIndexSearcher(SearchContext searchContext, Engine.Searcher searcher) { + super(searcher.searcher()); this.searchContext = searchContext; } - public IndexReader[] subReaders() { - return this.subReaders; - } - - public int[] docStarts() { - return this.docStarts; - } - - // taken from DirectoryReader#readerIndex - - public int readerIndex(int doc) { - int lo = 0; // search starts array - int hi = subReaders.length - 1; // for first element less - - while (hi >= lo) { - int mid = (lo + hi) >>> 1; - int midValue = docStarts[mid]; - if (doc < midValue) - hi = mid - 1; - else if (doc > midValue) - lo = mid + 1; - else { // found a match - while (mid + 1 < subReaders.length && docStarts[mid + 1] == midValue) { - mid++; // scan to last match - } - return mid; - } - } - return hi; - } - public void dfSource(CachedDfSource dfSource) { this.dfSource = dfSource; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/SearchContext.java b/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/SearchContext.java index 833964d46e2bb..4687e23969fd7 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/SearchContext.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/search/internal/SearchContext.java @@ -129,7 +129,7 @@ public SearchContext(long id, SearchShardTarget shardTarget, TimeValue timeout, this.fetchResult = new FetchSearchResult(id, shardTarget); this.indexService = indexService; - this.searcher = new ContextIndexSearcher(this, engineSearcher.reader()); + this.searcher = new ContextIndexSearcher(this, engineSearcher); } @Override public boolean release() throws ElasticSearchException {
0a8d1af2e53c3fbfe5dc5261d052dc03fd01fb79
Valadoc
gtkdoc-importer: Add support for refsect3
a
https://github.com/GNOME/vala/
diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/src/libvaladoc/documentation/gtkdoccommentparser.vala index af547f4beb..4c5a236b51 100644 --- a/src/libvaladoc/documentation/gtkdoccommentparser.vala +++ b/src/libvaladoc/documentation/gtkdoccommentparser.vala @@ -912,9 +912,9 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { return content; } - private LinkedList<Block>? parse_docbook_refsect2 () { - if (!check_xml_open_tag ("refsect2")) { - this.report_unexpected_token (current, "<refsect2>"); + private LinkedList<Block>? parse_docbook_refsect2 (int nr = 2) { + if (!check_xml_open_tag ("refsect%d".printf (nr))) { + this.report_unexpected_token (current, "<refsect%d>".printf (nr)); return null; } @@ -928,8 +928,8 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { this.append_block_content_not_null_all (content, parse_mixed_content ()); - if (!check_xml_close_tag ("refsect2")) { - this.report_unexpected_token (current, "</refsect2>"); + if (!check_xml_close_tag ("refsect%d".printf (nr))) { + this.report_unexpected_token (current, "</refsect%d>".printf (nr)); return content; } @@ -1395,6 +1395,8 @@ public class Valadoc.Gtkdoc.Parser : Object, ResourceLocator { this.append_block_content_not_null (content, parse_docbook_note ()); } else if (current.type == TokenType.XML_OPEN && current.content == "important") { this.append_block_content_not_null (content, parse_docbook_important ()); + } else if (current.type == TokenType.XML_OPEN && current.content == "refsect3") { + this.append_block_content_not_null_all (content, parse_docbook_refsect2 (3)); } else if (current.type == TokenType.XML_OPEN && current.content == "refsect2") { this.append_block_content_not_null_all (content, parse_docbook_refsect2 ()); } else if (current.type == TokenType.XML_OPEN && current.content == "figure") {
37a848bb108d6b8540f0ae03ce56febaf892e959
Search_api
Issue #2155127 by drunken monkey: Clarified the scope of the "Node access" and "Exclude unpublished nodes" data alterations.
a
https://github.com/lucidworks/drupal_search_api
diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1f9f6da6..142740a9 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,7 @@ Search API 1.x, dev (xx/xx/xxxx): --------------------------------- +- #2155127 by drunken monkey: Clarified the scope of the "Node access" and + "Exclude unpublished nodes" data alterations. - #2155575 by drunken monkey: Fixed incorrect "Server index status" warnings. - #2159011 by idebr, drunken monkey: Fixed highlighting of keywords with PCRE special characters. diff --git a/search_api.module b/search_api.module index 35ee56f7..000cadb2 100644 --- a/search_api.module +++ b/search_api.module @@ -1012,17 +1012,17 @@ function search_api_search_api_alter_callback_info() { ); $callbacks['search_api_alter_node_access'] = array( 'name' => t('Node access'), - 'description' => t('Add node access information to the index.'), + 'description' => t('Add node access information to the index. <strong>Caution:</strong> This only affects the indexed nodes themselves, not any node reference fields that are indexed with them, or displayed in search results.'), 'class' => 'SearchApiAlterNodeAccess', ); $callbacks['search_api_alter_comment_access'] = array( 'name' => t('Access check'), - 'description' => t('Add node access information to the index.'), + 'description' => t('Add node access information to the index. <strong>Caution:</strong> This only affects the indexed nodes themselves, not any node reference fields that are indexed with them, or displayed in search results.'), 'class' => 'SearchApiAlterCommentAccess', ); $callbacks['search_api_alter_node_status'] = array( 'name' => t('Exclude unpublished nodes'), - 'description' => t('Exclude unpublished nodes from the index.'), + 'description' => t('Exclude unpublished nodes from the index. <strong>Caution:</strong> This only affects the indexed nodes themselves. If an enabled node has references to disabled nodes, those will still be indexed (or displayed) normally.'), 'class' => 'SearchApiAlterNodeStatus', );
6368578020adf4796ac899ef2b0b9a695c59601c
ReactiveX-RxJava
unit tests for covariance--- refactoring so not everything for the entire Observable ends up in a single class-
p
https://github.com/ReactiveX/RxJava
diff --git a/rxjava-core/src/test/java/rx/CombineLatestTests.java b/rxjava-core/src/test/java/rx/CombineLatestTests.java new file mode 100644 index 0000000000..78dbd4c4e3 --- /dev/null +++ b/rxjava-core/src/test/java/rx/CombineLatestTests.java @@ -0,0 +1,53 @@ +package rx; + +import org.junit.Test; + +import rx.CovarianceTest.CoolRating; +import rx.CovarianceTest.ExtendedResult; +import rx.CovarianceTest.HorrorMovie; +import rx.CovarianceTest.Media; +import rx.CovarianceTest.Movie; +import rx.CovarianceTest.Rating; +import rx.CovarianceTest.Result; +import rx.util.functions.Action1; +import rx.util.functions.Func2; + +public class CombineLatestTests { + /** + * This won't compile if super/extends isn't done correctly on generics + */ + @Test + public void testCovarianceOfCombineLatest() { + Observable<HorrorMovie> horrors = Observable.from(new HorrorMovie()); + Observable<CoolRating> ratings = Observable.from(new CoolRating()); + + Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(action); + Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(action); + Observable.<Media, Rating, ExtendedResult> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(extendedAction); + Observable.<Media, Rating, Result> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(action); + Observable.<Media, Rating, ExtendedResult> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(action); + + Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine); + } + + Func2<Media, Rating, ExtendedResult> combine = new Func2<Media, Rating, ExtendedResult>() { + @Override + public ExtendedResult call(Media m, Rating r) { + return new ExtendedResult(); + } + }; + + Action1<Result> action = new Action1<Result>() { + @Override + public void call(Result t1) { + System.out.println("Result: " + t1); + } + }; + + Action1<ExtendedResult> extendedAction = new Action1<ExtendedResult>() { + @Override + public void call(ExtendedResult t1) { + System.out.println("Result: " + t1); + } + }; +} diff --git a/rxjava-core/src/test/java/rx/ConcatTests.java b/rxjava-core/src/test/java/rx/ConcatTests.java index 524b7fd73f..29a51d8dfe 100644 --- a/rxjava-core/src/test/java/rx/ConcatTests.java +++ b/rxjava-core/src/test/java/rx/ConcatTests.java @@ -7,6 +7,12 @@ import org.junit.Test; +import rx.CovarianceTest.HorrorMovie; +import rx.CovarianceTest.Media; +import rx.CovarianceTest.Movie; +import rx.Observable.OnSubscribeFunc; +import rx.subscriptions.Subscriptions; + public class ConcatTests { @Test @@ -54,4 +60,62 @@ public void testConcatWithIterableOfObservable() { assertEquals("three", values.get(2)); assertEquals("four", values.get(3)); } + + @Test + public void testConcatCovariance() { + Observable<Media> o1 = Observable.<Media> from(new HorrorMovie(), new Movie()); + Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); + + Observable<Observable<Media>> os = Observable.from(o1, o2); + + List<Media> values = Observable.concat(os).toList().toBlockingObservable().single(); + } + + @Test + public void testConcatCovariance2() { + Observable<Media> o1 = Observable.from(new HorrorMovie(), new Movie(), new Media()); + Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); + + Observable<Observable<Media>> os = Observable.from(o1, o2); + + List<Media> values = Observable.concat(os).toList().toBlockingObservable().single(); + } + + @Test + public void testConcatCovariance3() { + Observable<Movie> o1 = Observable.from(new HorrorMovie(), new Movie()); + Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); + + List<Media> values = Observable.concat(o1, o2).toList().toBlockingObservable().single(); + + assertTrue(values.get(0) instanceof HorrorMovie); + assertTrue(values.get(1) instanceof Movie); + assertTrue(values.get(2) instanceof Media); + assertTrue(values.get(3) instanceof HorrorMovie); + } + + @Test + public void testConcatCovariance4() { + + Observable<Movie> o1 = Observable.create(new OnSubscribeFunc<Movie>() { + + @Override + public Subscription onSubscribe(Observer<? super Movie> o) { + o.onNext(new HorrorMovie()); + o.onNext(new Movie()); + // o.onNext(new Media()); // correctly doesn't compile + o.onCompleted(); + return Subscriptions.empty(); + } + }); + + Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); + + List<Media> values = Observable.concat(o1, o2).toList().toBlockingObservable().single(); + + assertTrue(values.get(0) instanceof HorrorMovie); + assertTrue(values.get(1) instanceof Movie); + assertTrue(values.get(2) instanceof Media); + assertTrue(values.get(3) instanceof HorrorMovie); + } } diff --git a/rxjava-core/src/test/java/rx/CovarianceTest.java b/rxjava-core/src/test/java/rx/CovarianceTest.java index 4eb31f0da1..69110b6c6a 100644 --- a/rxjava-core/src/test/java/rx/CovarianceTest.java +++ b/rxjava-core/src/test/java/rx/CovarianceTest.java @@ -1,17 +1,9 @@ package rx; -import static org.junit.Assert.*; - import java.util.ArrayList; -import java.util.List; import org.junit.Test; -import rx.Observable.OnSubscribeFunc; -import rx.subscriptions.Subscriptions; -import rx.util.functions.Action1; -import rx.util.functions.Func2; - /** * Test super/extends of generics. * @@ -29,187 +21,9 @@ public void testCovarianceOfFrom() { // Observable.<HorrorMovie>from(new Movie()); // may not compile } - /** - * This won't compile if super/extends isn't done correctly on generics - */ - @Test - public void testCovarianceOfMerge() { - Observable<HorrorMovie> horrors = Observable.from(new HorrorMovie()); - Observable<Observable<HorrorMovie>> metaHorrors = Observable.just(horrors); - Observable.<Media> merge(metaHorrors); - } - - /** - * This won't compile if super/extends isn't done correctly on generics - */ - @Test - public void testCovarianceOfZip() { - Observable<HorrorMovie> horrors = Observable.from(new HorrorMovie()); - Observable<CoolRating> ratings = Observable.from(new CoolRating()); - - Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine).toBlockingObservable().forEach(action); - Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine).toBlockingObservable().forEach(action); - Observable.<Media, Rating, ExtendedResult> zip(horrors, ratings, combine).toBlockingObservable().forEach(extendedAction); - Observable.<Media, Rating, Result> zip(horrors, ratings, combine).toBlockingObservable().forEach(action); - Observable.<Media, Rating, ExtendedResult> zip(horrors, ratings, combine).toBlockingObservable().forEach(action); - - Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine); - } - - /** - * This won't compile if super/extends isn't done correctly on generics + /* + * Most tests are moved into their applicable classes such as [Operator]Tests.java */ - @Test - public void testCovarianceOfCombineLatest() { - Observable<HorrorMovie> horrors = Observable.from(new HorrorMovie()); - Observable<CoolRating> ratings = Observable.from(new CoolRating()); - - Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(action); - Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(action); - Observable.<Media, Rating, ExtendedResult> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(extendedAction); - Observable.<Media, Rating, Result> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(action); - Observable.<Media, Rating, ExtendedResult> combineLatest(horrors, ratings, combine).toBlockingObservable().forEach(action); - - Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine); - } - - @Test - public void testConcatCovariance() { - Observable<Media> o1 = Observable.<Media> from(new HorrorMovie(), new Movie()); - Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); - - Observable<Observable<Media>> os = Observable.from(o1, o2); - - List<Media> values = Observable.concat(os).toList().toBlockingObservable().single(); - } - - @Test - public void testConcatCovariance2() { - Observable<Media> o1 = Observable.from(new HorrorMovie(), new Movie(), new Media()); - Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); - - Observable<Observable<Media>> os = Observable.from(o1, o2); - - List<Media> values = Observable.concat(os).toList().toBlockingObservable().single(); - } - - @Test - public void testConcatCovariance3() { - Observable<Movie> o1 = Observable.from(new HorrorMovie(), new Movie()); - Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); - - List<Media> values = Observable.concat(o1, o2).toList().toBlockingObservable().single(); - - assertTrue(values.get(0) instanceof HorrorMovie); - assertTrue(values.get(1) instanceof Movie); - assertTrue(values.get(2) instanceof Media); - assertTrue(values.get(3) instanceof HorrorMovie); - } - - @Test - public void testConcatCovariance4() { - - Observable<Movie> o1 = Observable.create(new OnSubscribeFunc<Movie>() { - - @Override - public Subscription onSubscribe(Observer<? super Movie> o) { - o.onNext(new HorrorMovie()); - o.onNext(new Movie()); - // o.onNext(new Media()); // correctly doesn't compile - o.onCompleted(); - return Subscriptions.empty(); - } - }); - - Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); - - List<Media> values = Observable.concat(o1, o2).toList().toBlockingObservable().single(); - - assertTrue(values.get(0) instanceof HorrorMovie); - assertTrue(values.get(1) instanceof Movie); - assertTrue(values.get(2) instanceof Media); - assertTrue(values.get(3) instanceof HorrorMovie); - } - - - @Test - public void testMergeCovariance() { - Observable<Media> o1 = Observable.<Media> from(new HorrorMovie(), new Movie()); - Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); - - Observable<Observable<Media>> os = Observable.from(o1, o2); - - List<Media> values = Observable.merge(os).toList().toBlockingObservable().single(); - } - - @Test - public void testMergeCovariance2() { - Observable<Media> o1 = Observable.from(new HorrorMovie(), new Movie(), new Media()); - Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); - - Observable<Observable<Media>> os = Observable.from(o1, o2); - - List<Media> values = Observable.merge(os).toList().toBlockingObservable().single(); - } - - @Test - public void testMergeCovariance3() { - Observable<Movie> o1 = Observable.from(new HorrorMovie(), new Movie()); - Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); - - List<Media> values = Observable.merge(o1, o2).toList().toBlockingObservable().single(); - - assertTrue(values.get(0) instanceof HorrorMovie); - assertTrue(values.get(1) instanceof Movie); - assertTrue(values.get(2) instanceof Media); - assertTrue(values.get(3) instanceof HorrorMovie); - } - - @Test - public void testMergeCovariance4() { - - Observable<Movie> o1 = Observable.create(new OnSubscribeFunc<Movie>() { - - @Override - public Subscription onSubscribe(Observer<? super Movie> o) { - o.onNext(new HorrorMovie()); - o.onNext(new Movie()); - // o.onNext(new Media()); // correctly doesn't compile - o.onCompleted(); - return Subscriptions.empty(); - } - }); - - Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); - - List<Media> values = Observable.merge(o1, o2).toList().toBlockingObservable().single(); - - assertTrue(values.get(0) instanceof HorrorMovie); - assertTrue(values.get(1) instanceof Movie); - assertTrue(values.get(2) instanceof Media); - assertTrue(values.get(3) instanceof HorrorMovie); - } - - Func2<Media, Rating, ExtendedResult> combine = new Func2<Media, Rating, ExtendedResult>() { - @Override - public ExtendedResult call(Media m, Rating r) { - return new ExtendedResult(); - } - }; - - Action1<Result> action = new Action1<Result>() { - @Override - public void call(Result t1) { - System.out.println("Result: " + t1); - } - }; - - Action1<ExtendedResult> extendedAction = new Action1<ExtendedResult>() { - @Override - public void call(ExtendedResult t1) { - System.out.println("Result: " + t1); - } - }; static class Media { } diff --git a/rxjava-core/src/test/java/rx/MergeTests.java b/rxjava-core/src/test/java/rx/MergeTests.java new file mode 100644 index 0000000000..11f30c7908 --- /dev/null +++ b/rxjava-core/src/test/java/rx/MergeTests.java @@ -0,0 +1,86 @@ +package rx; + +import static org.junit.Assert.*; + +import java.util.List; + +import org.junit.Test; + +import rx.CovarianceTest.HorrorMovie; +import rx.CovarianceTest.Media; +import rx.CovarianceTest.Movie; +import rx.Observable.OnSubscribeFunc; +import rx.subscriptions.Subscriptions; + +public class MergeTests { + + /** + * This won't compile if super/extends isn't done correctly on generics + */ + @Test + public void testCovarianceOfMerge() { + Observable<HorrorMovie> horrors = Observable.from(new HorrorMovie()); + Observable<Observable<HorrorMovie>> metaHorrors = Observable.just(horrors); + Observable.<Media> merge(metaHorrors); + } + + @Test + public void testMergeCovariance() { + Observable<Media> o1 = Observable.<Media> from(new HorrorMovie(), new Movie()); + Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); + + Observable<Observable<Media>> os = Observable.from(o1, o2); + + List<Media> values = Observable.merge(os).toList().toBlockingObservable().single(); + } + + @Test + public void testMergeCovariance2() { + Observable<Media> o1 = Observable.from(new HorrorMovie(), new Movie(), new Media()); + Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); + + Observable<Observable<Media>> os = Observable.from(o1, o2); + + List<Media> values = Observable.merge(os).toList().toBlockingObservable().single(); + } + + @Test + public void testMergeCovariance3() { + Observable<Movie> o1 = Observable.from(new HorrorMovie(), new Movie()); + Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); + + List<Media> values = Observable.merge(o1, o2).toList().toBlockingObservable().single(); + + assertTrue(values.get(0) instanceof HorrorMovie); + assertTrue(values.get(1) instanceof Movie); + assertTrue(values.get(2) instanceof Media); + assertTrue(values.get(3) instanceof HorrorMovie); + } + + @Test + public void testMergeCovariance4() { + + Observable<Movie> o1 = Observable.create(new OnSubscribeFunc<Movie>() { + + @Override + public Subscription onSubscribe(Observer<? super Movie> o) { + o.onNext(new HorrorMovie()); + o.onNext(new Movie()); + // o.onNext(new Media()); // correctly doesn't compile + o.onCompleted(); + return Subscriptions.empty(); + } + }); + + Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie()); + + List<Media> values = Observable.merge(o1, o2).toList().toBlockingObservable().single(); + + assertTrue(values.get(0) instanceof HorrorMovie); + assertTrue(values.get(1) instanceof Movie); + assertTrue(values.get(2) instanceof Media); + assertTrue(values.get(3) instanceof HorrorMovie); + } + + +} diff --git a/rxjava-core/src/test/java/rx/ReduceTests.java b/rxjava-core/src/test/java/rx/ReduceTests.java new file mode 100644 index 0000000000..822001e615 --- /dev/null +++ b/rxjava-core/src/test/java/rx/ReduceTests.java @@ -0,0 +1,69 @@ +package rx; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import rx.CovarianceTest.HorrorMovie; +import rx.CovarianceTest.Movie; +import rx.operators.OperationScan; +import rx.util.functions.Func2; + +public class ReduceTests { + + @Test + public void reduceInts() { + Observable<Integer> o = Observable.from(1, 2, 3); + int value = o.reduce(new Func2<Integer, Integer, Integer>() { + + @Override + public Integer call(Integer t1, Integer t2) { + return t1 + t2; + } + }).toBlockingObservable().single(); + + assertEquals(6, value); + } + + @Test + public void reduceWithObjects() { + Observable<HorrorMovie> horrorMovies = Observable.from(new HorrorMovie()); + + Func2<Movie, Movie, Movie> chooseSecondMovie = + new Func2<Movie, Movie, Movie>() { + public Movie call(Movie t1, Movie t2) { + return t2; + } + }; + + Observable<Movie> reduceResult = Observable.create(OperationScan.scan(horrorMovies, chooseSecondMovie)).takeLast(1); + + //TODO this isn't compiling + // Observable<Movie> reduceResult2 = horrorMovies.reduce(chooseSecondMovie); + } + + @Test + public void reduceCovariance() { + Observable<HorrorMovie> horrorMovies = Observable.from(new HorrorMovie()); + + // do something with horrorMovies, relying on the fact that all are HorrorMovies + // and not just any Movies... + + // pass it to library (works because it takes Observable<? extends Movie>) + libraryFunctionActingOnMovieObservables(horrorMovies); + } + + public void libraryFunctionActingOnMovieObservables(Observable<? extends Movie> obs) { + Func2<Movie, Movie, Movie> chooseSecondMovie = + new Func2<Movie, Movie, Movie>() { + public Movie call(Movie t1, Movie t2) { + return t2; + } + }; + + //TODO this isn't compiling + // Observable<Movie> reduceResult = obs.reduce((Func2<? super Movie, ? super Movie, ? extends Movie>) chooseSecondMovie); + // do something with reduceResult... + } + +} diff --git a/rxjava-core/src/test/java/rx/ZipTests.java b/rxjava-core/src/test/java/rx/ZipTests.java new file mode 100644 index 0000000000..ee25bb6ade --- /dev/null +++ b/rxjava-core/src/test/java/rx/ZipTests.java @@ -0,0 +1,54 @@ +package rx; + +import org.junit.Test; + +import rx.CovarianceTest.CoolRating; +import rx.CovarianceTest.ExtendedResult; +import rx.CovarianceTest.HorrorMovie; +import rx.CovarianceTest.Media; +import rx.CovarianceTest.Movie; +import rx.CovarianceTest.Rating; +import rx.CovarianceTest.Result; +import rx.util.functions.Action1; +import rx.util.functions.Func2; + +public class ZipTests { + + /** + * This won't compile if super/extends isn't done correctly on generics + */ + @Test + public void testCovarianceOfZip() { + Observable<HorrorMovie> horrors = Observable.from(new HorrorMovie()); + Observable<CoolRating> ratings = Observable.from(new CoolRating()); + + Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine).toBlockingObservable().forEach(action); + Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine).toBlockingObservable().forEach(action); + Observable.<Media, Rating, ExtendedResult> zip(horrors, ratings, combine).toBlockingObservable().forEach(extendedAction); + Observable.<Media, Rating, Result> zip(horrors, ratings, combine).toBlockingObservable().forEach(action); + Observable.<Media, Rating, ExtendedResult> zip(horrors, ratings, combine).toBlockingObservable().forEach(action); + + Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine); + } + + Func2<Media, Rating, ExtendedResult> combine = new Func2<Media, Rating, ExtendedResult>() { + @Override + public ExtendedResult call(Media m, Rating r) { + return new ExtendedResult(); + } + }; + + Action1<Result> action = new Action1<Result>() { + @Override + public void call(Result t1) { + System.out.println("Result: " + t1); + } + }; + + Action1<ExtendedResult> extendedAction = new Action1<ExtendedResult>() { + @Override + public void call(ExtendedResult t1) { + System.out.println("Result: " + t1); + } + }; +}
3d6253c27fbba7cb88626eead38ec18449ffd7bf
kotlin
abstract + data and sealed + data are also- deprecated--
p
https://github.com/JetBrains/kotlin
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt index 9d2f63b05319d..cb2181c4eb52c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt @@ -100,9 +100,11 @@ public object ModifierCheckerCore { result += incompatibilityRegister(PRIVATE_KEYWORD, PROTECTED_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD) // Abstract + open + final + sealed: incompatible result += incompatibilityRegister(ABSTRACT_KEYWORD, OPEN_KEYWORD, FINAL_KEYWORD, SEALED_KEYWORD) - // data + open, data + inner + // data + open, data + inner, data + abstract, data + sealed result += deprecationRegister(DATA_KEYWORD, OPEN_KEYWORD) result += deprecationRegister(DATA_KEYWORD, INNER_KEYWORD) + result += deprecationRegister(DATA_KEYWORD, ABSTRACT_KEYWORD) + result += deprecationRegister(DATA_KEYWORD, SEALED_KEYWORD) // open is redundant to abstract & override result += redundantRegister(ABSTRACT_KEYWORD, OPEN_KEYWORD) result += redundantRegister(OVERRIDE_KEYWORD, OPEN_KEYWORD) diff --git a/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt b/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt index 86661a48de69b..febb864722619 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/dataInheritance.kt @@ -2,7 +2,7 @@ interface Allowed open class NotAllowed -abstract data class Base(val x: Int) +<!DEPRECATED_MODIFIER_PAIR!>abstract<!> <!DEPRECATED_MODIFIER_PAIR!>data<!> class Base(val x: Int) class Derived: Base(42) diff --git a/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.kt b/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.kt new file mode 100644 index 0000000000000..8aabf0580394f --- /dev/null +++ b/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.kt @@ -0,0 +1,4 @@ +<!DEPRECATED_MODIFIER_PAIR!>sealed<!> <!DEPRECATED_MODIFIER_PAIR!>data<!> class My(val x: Int) { + object Your: My(1) + class His(y: Int): My(y) +} diff --git a/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.txt b/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.txt new file mode 100644 index 0000000000000..5a3e8f487091a --- /dev/null +++ b/compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.txt @@ -0,0 +1,31 @@ +package + [email protected]() public sealed class My { + private constructor My(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + public final /*synthesized*/ fun component1(): kotlin.Int + public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): My + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class His : My { + public constructor His(/*0*/ y: kotlin.Int) + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public final override /*1*/ /*fake_override*/ fun component1(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun copy(/*0*/ x: kotlin.Int = ...): My + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public object Your : My { + private constructor Your() + public final override /*1*/ /*fake_override*/ val x: kotlin.Int + public final override /*1*/ /*fake_override*/ fun component1(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun copy(/*0*/ x: kotlin.Int = ...): My + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index c7ad9833c5051..44ddcffb7451c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -3414,6 +3414,12 @@ public void testRepeatedProperties() throws Exception { doTest(fileName); } + @TestMetadata("sealedDataClass.kt") + public void testSealedDataClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/sealedDataClass.kt"); + doTest(fileName); + } + @TestMetadata("secondParamIsVal.kt") public void testSecondParamIsVal() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dataClasses/secondParamIsVal.kt");
0135f0311318d8596fdeabca9f266cdac8f5589b
camel
CAMEL-6048: camel-xmljson fixed issue so- attrbiutes with name type can be serialized. Thanks to Arne M Stroksen for- the patch.--git-svn-id: https://svn.apache.org/repos/asf/camel/trunk@1443634 13f79535-47bb-0310-9956-ffa450edef68-
c
https://github.com/apache/camel
diff --git a/components/camel-xmljson/src/main/java/org/apache/camel/dataformat/xmljson/XmlJsonDataFormat.java b/components/camel-xmljson/src/main/java/org/apache/camel/dataformat/xmljson/XmlJsonDataFormat.java index 103de3814dcfc..1120d73fc6cc3 100644 --- a/components/camel-xmljson/src/main/java/org/apache/camel/dataformat/xmljson/XmlJsonDataFormat.java +++ b/components/camel-xmljson/src/main/java/org/apache/camel/dataformat/xmljson/XmlJsonDataFormat.java @@ -120,6 +120,7 @@ protected void doStart() throws Exception { } } else { serializer.setTypeHintsEnabled(false); + serializer.setTypeHintsCompatibility(false); } } diff --git a/components/camel-xmljson/src/test/java/org/apache/camel/dataformat/xmljson/XmlJsonOptionsTest.java b/components/camel-xmljson/src/test/java/org/apache/camel/dataformat/xmljson/XmlJsonOptionsTest.java index 2d681593761cd..8c5b20abbabf2 100644 --- a/components/camel-xmljson/src/test/java/org/apache/camel/dataformat/xmljson/XmlJsonOptionsTest.java +++ b/components/camel-xmljson/src/test/java/org/apache/camel/dataformat/xmljson/XmlJsonOptionsTest.java @@ -53,6 +53,24 @@ public void testSomeOptionsToJSON() throws Exception { mockJSON.assertIsSatisfied(); } + @Test + public void testXmlWithTypeAttributesToJSON() throws Exception { + InputStream inStream = getClass().getClassLoader().getResourceAsStream("org/apache/camel/dataformat/xmljson/testMessage4.xml"); + String in = context.getTypeConverter().convertTo(String.class, inStream); + + MockEndpoint mockJSON = getMockEndpoint("mock:json"); + mockJSON.expectedMessageCount(1); + mockJSON.message(0).body().isInstanceOf(byte[].class); + + Object json = template.requestBody("direct:marshal", in); + String jsonString = context.getTypeConverter().convertTo(String.class, json); + JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString); + assertEquals("JSON must contain 1 top-level element", 1, obj.entrySet().size()); + assertTrue("Top-level element must be named root", obj.has("root")); + + mockJSON.assertIsSatisfied(); + } + @Test public void testSomeOptionsToXML() throws Exception { InputStream inStream = getClass().getClassLoader().getResourceAsStream("org/apache/camel/dataformat/xmljson/testMessage1.json"); diff --git a/components/camel-xmljson/src/test/resources/org/apache/camel/dataformat/xmljson/testMessage4.xml b/components/camel-xmljson/src/test/resources/org/apache/camel/dataformat/xmljson/testMessage4.xml new file mode 100644 index 0000000000000..05e498379d32c --- /dev/null +++ b/components/camel-xmljson/src/test/resources/org/apache/camel/dataformat/xmljson/testMessage4.xml @@ -0,0 +1,16 @@ +<root type="atype"> + <a>1</a> + <b>2</b> + <c type="anothertype"> + <a>c.a.1</a> + <b>c.b.2</b> + </c> + <d>a</d> + <d>b</d> + <d>c</d> + <e>1</e> + <e>2</e> + <e>3</e> + <f>true</f> + <g /> +</root> \ No newline at end of file
98e3eb8204423d1e5ff8fc49230c52273ac8f5b4
Valadoc
devhelp: Generate better keywords
a
https://github.com/GNOME/vala/
diff --git a/src/doclets/devhelp/doclet.vala b/src/doclets/devhelp/doclet.vala index b3747af049..b776f5e37b 100644 --- a/src/doclets/devhelp/doclet.vala +++ b/src/doclets/devhelp/doclet.vala @@ -129,7 +129,7 @@ public class Valadoc.Devhelp.Doclet : Valadoc.Html.BasicDoclet { } _devhelpwriter.simple_tag ("keyword", {"type", typekeyword, - "name", node.name, + "name", node.get_full_name (), "link", get_link (node, node.package)}); } _devhelpwriter.end_functions ();
52c58115d2a0b97908bacdd7fb6a78a6b6cf3e83
hadoop
YARN-2798. Fixed YarnClient to populate the renewer- correctly for Timeline delegation tokens. Contributed by Zhijie Shen.--(cherry picked from commit 71fbb474f531f60c5d908cf724f18f90dfd5fa9f)-
c
https://github.com/apache/hadoop
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 56359e5b00736..5e2a1c2b1ae3b 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -812,6 +812,9 @@ Release 2.6.0 - UNRELEASED YARN-2730. DefaultContainerExecutor runs only one localizer at a time (Siqi Li via jlowe) + YARN-2798. Fixed YarnClient to populate the renewer correctly for Timeline + delegation tokens. (Zhijie Shen via vinodkv) + Release 2.5.1 - 2014-09-05 INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java index 1193cb4c8b49e..e4f31f20d848c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/YarnClientImpl.java @@ -36,7 +36,7 @@ import org.apache.hadoop.io.Text; import org.apache.hadoop.ipc.RPC; import org.apache.hadoop.security.Credentials; -import org.apache.hadoop.security.HadoopKerberosName; +import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.token.TokenIdentifier; import org.apache.hadoop.yarn.api.ApplicationClientProtocol; @@ -51,7 +51,6 @@ import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodeLabelsRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodeLabelsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetContainerReportRequest; @@ -124,6 +123,8 @@ public class YarnClientImpl extends YarnClient { protected TimelineClient timelineClient; @VisibleForTesting Text timelineService; + @VisibleForTesting + String timelineDTRenewer; protected boolean timelineServiceEnabled; private static final String ROOT = "root"; @@ -161,6 +162,7 @@ protected void serviceInit(Configuration conf) throws Exception { timelineServiceEnabled = true; timelineClient = TimelineClient.createTimelineClient(); timelineClient.init(conf); + timelineDTRenewer = getTimelineDelegationTokenRenewer(conf); timelineService = TimelineUtils.buildTimelineTokenService(conf); } super.serviceInit(conf); @@ -320,14 +322,22 @@ private void addTimelineDelegationToken( @VisibleForTesting org.apache.hadoop.security.token.Token<TimelineDelegationTokenIdentifier> getTimelineDelegationToken() throws IOException, YarnException { + return timelineClient.getDelegationToken(timelineDTRenewer); + } + + private static String getTimelineDelegationTokenRenewer(Configuration conf) + throws IOException, YarnException { // Parse the RM daemon user if it exists in the config - String rmPrincipal = getConfig().get(YarnConfiguration.RM_PRINCIPAL); + String rmPrincipal = conf.get(YarnConfiguration.RM_PRINCIPAL); String renewer = null; if (rmPrincipal != null && rmPrincipal.length() > 0) { - HadoopKerberosName renewerKrbName = new HadoopKerberosName(rmPrincipal); - renewer = renewerKrbName.getShortName(); + String rmHost = conf.getSocketAddr( + YarnConfiguration.RM_ADDRESS, + YarnConfiguration.DEFAULT_RM_ADDRESS, + YarnConfiguration.DEFAULT_RM_PORT).getHostName(); + renewer = SecurityUtil.getServerPrincipal(rmPrincipal, rmHost); } - return timelineClient.getDelegationToken(renewer); + return renewer; } @Private diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java index d7bea7a8d0a7a..ca7c50a1270af 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/api/impl/TestYarnClient.java @@ -852,7 +852,25 @@ public boolean isSecurityEnabled() { client.stop(); } } - + + @Test + public void testParseTimelineDelegationTokenRenewer() throws Exception { + // Client side + YarnClientImpl client = (YarnClientImpl) YarnClient.createYarnClient(); + Configuration conf = new YarnConfiguration(); + conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true); + conf.set(YarnConfiguration.RM_PRINCIPAL, "rm/[email protected]"); + conf.set( + YarnConfiguration.RM_ADDRESS, "localhost:8188"); + try { + client.init(conf); + client.start(); + Assert.assertEquals("rm/[email protected]", client.timelineDTRenewer); + } finally { + client.stop(); + } + } + @Test public void testReservationAPIs() { // initialize diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java index 2052c23159827..dc4f9e2a41dd8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/security/TestYARNTokenIdentifier.java @@ -19,14 +19,18 @@ import java.io.IOException; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.CommonConfigurationKeysPublic; import org.apache.hadoop.io.DataInputBuffer; import org.apache.hadoop.io.Text; +import org.apache.hadoop.security.HadoopKerberosName; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.Resource; +import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.security.client.ClientToAMTokenIdentifier; import org.apache.hadoop.yarn.security.client.RMDelegationTokenIdentifier; import org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier; @@ -299,4 +303,19 @@ public void testTimelineDelegationTokenIdentifier() throws IOException { anotherToken.getMasterKeyId(), masterKeyId); } + @Test + public void testParseTimelineDelegationTokenIdentifierRenewer() throws IOException { + // Server side when generation a timeline DT + Configuration conf = new YarnConfiguration(); + conf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTH_TO_LOCAL, + "RULE:[2:$1@$0]([nr]m@.*EXAMPLE.COM)s/.*/yarn/"); + HadoopKerberosName.setConfiguration(conf); + Text owner = new Text("owner"); + Text renewer = new Text("rm/[email protected]"); + Text realUser = new Text("realUser"); + TimelineDelegationTokenIdentifier token = + new TimelineDelegationTokenIdentifier(owner, renewer, realUser); + Assert.assertEquals(new Text("yarn"), token.getRenewer()); + } + }
44a27c5cd76f44e435671c69d1d8f60c42a2b420
hbase
HBASE-11920 Add CP hooks for ReplicationEndPoint--
a
https://github.com/apache/hbase
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterAndRegionObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterAndRegionObserver.java index 768481d55496..a6b9d848b212 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterAndRegionObserver.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseMasterAndRegionObserver.java @@ -19,23 +19,23 @@ package org.apache.hadoop.hbase.coprocessor; -import org.apache.hadoop.hbase.classification.InterfaceAudience; -import org.apache.hadoop.hbase.classification.InterfaceStability; +import java.io.IOException; +import java.util.List; + +import org.apache.hadoop.hbase.CoprocessorEnvironment; import org.apache.hadoop.hbase.HBaseInterfaceAudience; -import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HRegionInfo; -import org.apache.hadoop.hbase.CoprocessorEnvironment; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.master.RegionPlan; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription; import org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.Quotas; -import java.io.IOException; -import java.util.List; - @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) @InterfaceStability.Evolving public abstract class BaseMasterAndRegionObserver extends BaseRegionObserver diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseRegionServerObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseRegionServerObserver.java index 5bc23d3e6711..c21cdf884dc1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseRegionServerObserver.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseRegionServerObserver.java @@ -24,6 +24,7 @@ import org.apache.hadoop.hbase.HBaseInterfaceAudience; import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.regionserver.HRegion; +import org.apache.hadoop.hbase.replication.ReplicationEndpoint; /** * An abstract class that implements RegionServerObserver. @@ -76,4 +77,10 @@ public void preRollWALWriterRequest(ObserverContext<RegionServerCoprocessorEnvir public void postRollWALWriterRequest(ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { } + @Override + public ReplicationEndpoint postCreateReplicationEndPoint( + ObserverContext<RegionServerCoprocessorEnvironment> ctx, ReplicationEndpoint endpoint) { + return endpoint; + } + } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerObserver.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerObserver.java index 8a76d46d04f9..5c07fd2180a3 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerObserver.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/coprocessor/RegionServerObserver.java @@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.MetaMutationAnnotation; import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.regionserver.HRegion; +import org.apache.hadoop.hbase.replication.ReplicationEndpoint; public interface RegionServerObserver extends Coprocessor { @@ -121,4 +122,13 @@ void preRollWALWriterRequest(final ObserverContext<RegionServerCoprocessorEnviro void postRollWALWriterRequest(final ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException; + /** + * This will be called after the replication endpoint is instantiated. + * @param ctx + * @param endpoint - the base endpoint for replication + * @return the endpoint to use during replication. + */ + ReplicationEndpoint postCreateReplicationEndPoint( + ObserverContext<RegionServerCoprocessorEnvironment> ctx, ReplicationEndpoint endpoint); + } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java index 54552c622fe6..ec44560c32a6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerCoprocessorHost.java @@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.coprocessor.ObserverContext; import org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment; import org.apache.hadoop.hbase.coprocessor.RegionServerObserver; +import org.apache.hadoop.hbase.replication.ReplicationEndpoint; @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC) @InterfaceStability.Evolving @@ -156,6 +157,27 @@ public void call(RegionServerObserver oserver, }); } + public ReplicationEndpoint postCreateReplicationEndPoint(final ReplicationEndpoint endpoint) + throws IOException { + return execOperationWithResult(endpoint, coprocessors.isEmpty() ? null + : new CoprocessOperationWithResult<ReplicationEndpoint>() { + @Override + public void call(RegionServerObserver oserver, + ObserverContext<RegionServerCoprocessorEnvironment> ctx) throws IOException { + setResult(oserver.postCreateReplicationEndPoint(ctx, getResult())); + } + }); + } + + private <T> T execOperationWithResult(final T defaultValue, + final CoprocessOperationWithResult<T> ctx) throws IOException { + if (ctx == null) + return defaultValue; + ctx.setResult(defaultValue); + execOperation(ctx); + return ctx.getResult(); + } + private static abstract class CoprocessorOperation extends ObserverContext<RegionServerCoprocessorEnvironment> { public CoprocessorOperation() { @@ -168,6 +190,18 @@ public void postEnvCall(RegionServerEnvironment env) { } } + private static abstract class CoprocessOperationWithResult<T> extends CoprocessorOperation { + private T result = null; + + public void setResult(final T result) { + this.result = result; + } + + public T getResult() { + return this.result; + } + } + private boolean execOperation(final CoprocessorOperation ctx) throws IOException { if (ctx == null) return false; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java index a2f16675e6db..cb0f6ce68ff1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java @@ -39,11 +39,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.Stoppable; +import org.apache.hadoop.hbase.Server; +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.regionserver.HRegionServer; +import org.apache.hadoop.hbase.regionserver.RegionServerCoprocessorHost; import org.apache.hadoop.hbase.replication.ReplicationEndpoint; import org.apache.hadoop.hbase.replication.ReplicationException; import org.apache.hadoop.hbase.replication.ReplicationListener; @@ -84,7 +86,7 @@ public class ReplicationSourceManager implements ReplicationListener { // UUID for this cluster private final UUID clusterId; // All about stopping - private final Stoppable stopper; + private final Server server; // All logs we are currently tracking private final Map<String, SortedSet<String>> hlogsById; // Logs for recovered sources we are currently tracking @@ -111,7 +113,7 @@ public class ReplicationSourceManager implements ReplicationListener { * @param replicationPeers * @param replicationTracker * @param conf the configuration to use - * @param stopper the stopper object for this region server + * @param server the server for this region server * @param fs the file system to use * @param logDir the directory that contains all hlog directories of live RSs * @param oldLogDir the directory where old logs are archived @@ -119,7 +121,7 @@ public class ReplicationSourceManager implements ReplicationListener { */ public ReplicationSourceManager(final ReplicationQueues replicationQueues, final ReplicationPeers replicationPeers, final ReplicationTracker replicationTracker, - final Configuration conf, final Stoppable stopper, final FileSystem fs, final Path logDir, + final Configuration conf, final Server server, final FileSystem fs, final Path logDir, final Path oldLogDir, final UUID clusterId) { //CopyOnWriteArrayList is thread-safe. //Generally, reading is more than modifying. @@ -127,7 +129,7 @@ public ReplicationSourceManager(final ReplicationQueues replicationQueues, this.replicationQueues = replicationQueues; this.replicationPeers = replicationPeers; this.replicationTracker = replicationTracker; - this.stopper = stopper; + this.server = server; this.hlogsById = new HashMap<String, SortedSet<String>>(); this.hlogsByIdRecoveredQueues = new ConcurrentHashMap<String, SortedSet<String>>(); this.oldsources = new CopyOnWriteArrayList<ReplicationSourceInterface>(); @@ -243,7 +245,7 @@ protected ReplicationSourceInterface addSource(String id) throws IOException, ReplicationPeer peer = replicationPeers.getPeer(id); ReplicationSourceInterface src = getReplicationSource(this.conf, this.fs, this, this.replicationQueues, - this.replicationPeers, stopper, id, this.clusterId, peerConfig, peer); + this.replicationPeers, server, id, this.clusterId, peerConfig, peer); synchronized (this.hlogsById) { this.sources.add(src); this.hlogsById.put(id, new TreeSet<String>()); @@ -257,7 +259,7 @@ protected ReplicationSourceInterface addSource(String id) throws IOException, String message = "Cannot add log to queue when creating a new source, queueId=" + src.getPeerClusterZnode() + ", filename=" + name; - stopper.stop(message); + server.stop(message); throw e; } src.enqueueLog(this.latestPath); @@ -359,7 +361,7 @@ void postLogRoll(Path newLog) throws IOException { * @param conf the configuration to use * @param fs the file system to use * @param manager the manager to use - * @param stopper the stopper object for this region server + * @param server the server object for this region server * @param peerId the id of the peer cluster * @return the created source * @throws IOException @@ -367,9 +369,13 @@ void postLogRoll(Path newLog) throws IOException { protected ReplicationSourceInterface getReplicationSource(final Configuration conf, final FileSystem fs, final ReplicationSourceManager manager, final ReplicationQueues replicationQueues, final ReplicationPeers replicationPeers, - final Stoppable stopper, final String peerId, final UUID clusterId, + final Server server, final String peerId, final UUID clusterId, final ReplicationPeerConfig peerConfig, final ReplicationPeer replicationPeer) throws IOException { + RegionServerCoprocessorHost rsServerHost = null; + if (server instanceof HRegionServer) { + rsServerHost = ((HRegionServer) server).getRegionServerCoprocessorHost(); + } ReplicationSourceInterface src; try { @SuppressWarnings("rawtypes") @@ -392,6 +398,14 @@ protected ReplicationSourceInterface getReplicationSource(final Configuration co @SuppressWarnings("rawtypes") Class c = Class.forName(replicationEndpointImpl); replicationEndpoint = (ReplicationEndpoint) c.newInstance(); + if(rsServerHost != null) { + ReplicationEndpoint newReplicationEndPoint = rsServerHost + .postCreateReplicationEndPoint(replicationEndpoint); + if(newReplicationEndPoint != null) { + // Override the newly created endpoint from the hook with configured end point + replicationEndpoint = newReplicationEndPoint; + } + } } catch (Exception e) { LOG.warn("Passed replication endpoint implementation throws errors", e); throw new IOException(e); @@ -399,7 +413,7 @@ protected ReplicationSourceInterface getReplicationSource(final Configuration co MetricsSource metrics = new MetricsSource(peerId); // init replication source - src.init(conf, fs, manager, replicationQueues, replicationPeers, stopper, peerId, + src.init(conf, fs, manager, replicationQueues, replicationPeers, server, peerId, clusterId, replicationEndpoint, metrics); // init replication endpoint @@ -542,7 +556,7 @@ public void run() { Thread.currentThread().interrupt(); } // We try to lock that rs' queue directory - if (stopper.isStopped()) { + if (server.isStopped()) { LOG.info("Not transferring queue since we are shutting down"); return; } @@ -578,7 +592,7 @@ public void run() { ReplicationSourceInterface src = getReplicationSource(conf, fs, ReplicationSourceManager.this, this.rq, this.rp, - stopper, peerId, this.clusterId, peerConfig, peer); + server, peerId, this.clusterId, peerConfig, peer); if (!this.rp.getPeerIds().contains((src.getPeerClusterId()))) { src.terminate("Recovered queue doesn't belong to any current peer"); break; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java index 95cd72ac6db0..96c912a2efb0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java @@ -30,7 +30,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellScanner; @@ -45,13 +45,13 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue.Type; +import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableNotDisabledException; import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.Tag; -import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.client.Append; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Durability; @@ -91,6 +91,7 @@ import org.apache.hadoop.hbase.regionserver.ScanType; import org.apache.hadoop.hbase.regionserver.Store; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; +import org.apache.hadoop.hbase.replication.ReplicationEndpoint; import org.apache.hadoop.hbase.security.AccessDeniedException; import org.apache.hadoop.hbase.security.User; import org.apache.hadoop.hbase.security.UserProvider; @@ -2252,4 +2253,10 @@ public void preSetNamespaceQuota(final ObserverContext<MasterCoprocessorEnvironm final String namespace, final Quotas quotas) throws IOException { requirePermission("setNamespaceQuota", Action.ADMIN); } + + @Override + public ReplicationEndpoint postCreateReplicationEndPoint( + ObserverContext<RegionServerCoprocessorEnvironment> ctx, ReplicationEndpoint endpoint) { + return endpoint; + } }
8484cd9b9ed5b4e01aab4d2d58a4585d5aa2be64
tapiji
Separates UI and non-UI concerns for the core plug-in. Contributes Issue 73. * Adapts the Activator to extend `Plugin` instead of `AbstractUiPlugin` * Moves marker and nature management to `core.ui`
a
https://github.com/tapiji/tapiji
diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/InternationalizationNature.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/InternationalizationNature.java index 781916ec..fa4ea483 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/InternationalizationNature.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/builder/InternationalizationNature.java @@ -15,7 +15,7 @@ import java.util.List; import org.eclipse.babel.tapiji.tools.core.Logger; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectNature; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/decorators/ExcludedResource.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/decorators/ExcludedResource.java index 1f1963b0..57bfdfb7 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/decorators/ExcludedResource.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/decorators/ExcludedResource.java @@ -15,9 +15,9 @@ import org.eclipse.babel.tapiji.tools.core.Logger; import org.eclipse.babel.tapiji.tools.core.model.IResourceExclusionListener; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceExclusionEvent; import org.eclipse.babel.tapiji.tools.core.ui.Activator; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.ui.builder.InternationalizationNature; import org.eclipse.babel.tapiji.tools.core.ui.utils.ImageUtils; import org.eclipse.core.resources.IFile; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/QueryResourceBundleEntryDialog.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/QueryResourceBundleEntryDialog.java index 8f105f67..9c17b28c 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/QueryResourceBundleEntryDialog.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/QueryResourceBundleEntryDialog.java @@ -15,7 +15,7 @@ import java.util.Locale; import java.util.Set; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.ui.widgets.ResourceSelector; import org.eclipse.babel.tapiji.tools.core.ui.widgets.event.ResourceSelectionEvent; import org.eclipse.babel.tapiji.tools.core.ui.widgets.listener.IResourceSelectionListener; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/RemoveLanguageDialoge.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/RemoveLanguageDialoge.java index deafcb68..17b8721c 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/RemoveLanguageDialoge.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/RemoveLanguageDialoge.java @@ -13,7 +13,7 @@ import java.util.Locale; import java.util.Set; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.ui.utils.ImageUtils; import org.eclipse.core.resources.IProject; import org.eclipse.jface.viewers.ILabelProvider; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleEntrySelectionDialog.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleEntrySelectionDialog.java index 81aeda92..d204f767 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleEntrySelectionDialog.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleEntrySelectionDialog.java @@ -14,7 +14,7 @@ import java.util.Locale; import java.util.Set; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.ui.widgets.ResourceSelector; import org.eclipse.babel.tapiji.tools.core.ui.widgets.event.ResourceSelectionEvent; import org.eclipse.babel.tapiji.tools.core.ui.widgets.listener.IResourceSelectionListener; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/memento/ResourceBundleManagerStateLoader.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/memento/ResourceBundleManagerStateLoader.java index 8acda94d..3c09af58 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/memento/ResourceBundleManagerStateLoader.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/memento/ResourceBundleManagerStateLoader.java @@ -20,7 +20,7 @@ import org.eclipse.babel.tapiji.tools.core.model.IResourceDescriptor; import org.eclipse.babel.tapiji.tools.core.model.ResourceDescriptor; import org.eclipse.babel.tapiji.tools.core.model.manager.IStateLoader; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.util.FileUtils; import org.eclipse.ui.IMemento; import org.eclipse.ui.XMLMemento; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/preferences/TapiHomePreferencePage.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/preferences/TapiHomePreferencePage.java index 412c782b..b5f7d7ca 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/preferences/TapiHomePreferencePage.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/preferences/TapiHomePreferencePage.java @@ -8,7 +8,7 @@ * Contributors: * Martin Reiterer - initial API and implementation ******************************************************************************/ -package org.eclipse.babel.tapiji.tools.core.ui.prefrences; +package org.eclipse.babel.tapiji.tools.core.ui.preferences; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/quickfix/IncludeResource.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/quickfix/IncludeResource.java index 04883026..ea69e187 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/quickfix/IncludeResource.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/quickfix/IncludeResource.java @@ -12,7 +12,7 @@ import java.util.Set; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/MessagesView.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/MessagesView.java index cf3d73f8..df96cca3 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/MessagesView.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/MessagesView.java @@ -18,8 +18,8 @@ import org.eclipse.babel.tapiji.tools.core.Logger; import org.eclipse.babel.tapiji.tools.core.model.IResourceBundleChangedListener; import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleChangedEvent; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.ui.Activator; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.ui.dialogs.ResourceBundleSelectionDialog; import org.eclipse.babel.tapiji.tools.core.ui.utils.ImageUtils; import org.eclipse.babel.tapiji.tools.core.ui.widgets.PropertyKeySelectionTree; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/PropertyKeySelectionTree.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/PropertyKeySelectionTree.java index e534c6a1..3eec260f 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/PropertyKeySelectionTree.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/PropertyKeySelectionTree.java @@ -38,7 +38,7 @@ import org.eclipse.babel.tapiji.tools.core.Logger; import org.eclipse.babel.tapiji.tools.core.model.IResourceBundleChangedListener; import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleChangedEvent; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.ui.dialogs.CreateResourceBundleEntryDialog; import org.eclipse.babel.tapiji.tools.core.ui.dialogs.CreateResourceBundleEntryDialog.DialogConfiguration; import org.eclipse.babel.tapiji.tools.core.ui.utils.EditorUtils; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/ResourceSelector.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/ResourceSelector.java index c33262c9..dba51f8a 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/ResourceSelector.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/ResourceSelector.java @@ -20,7 +20,7 @@ import org.eclipse.babel.core.message.tree.IKeyTreeNode; import org.eclipse.babel.core.message.tree.TreeType; import org.eclipse.babel.editor.api.KeyTreeFactory; -import org.eclipse.babel.tapiji.tools.core.model.manager.ResourceBundleManager; +import org.eclipse.babel.tapiji.tools.core.ui.ResourceBundleManager; import org.eclipse.babel.tapiji.tools.core.ui.widgets.event.ResourceSelectionEvent; import org.eclipse.babel.tapiji.tools.core.ui.widgets.listener.IResourceSelectionListener; import org.eclipse.babel.tapiji.tools.core.ui.widgets.provider.ResKeyTreeContentProvider;
41a8d9ab2bd15c19edff0f374179fba4db5405a7
hbase
HBASE-2787 PE is confused about flushCommits--git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@957750 13f79535-47bb-0310-9956-ffa450edef68-
c
https://github.com/apache/hbase
diff --git a/CHANGES.txt b/CHANGES.txt index 3be1383ed323..53fd598b7541 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -422,6 +422,7 @@ Release 0.21.0 - Unreleased HBASE-2774 Spin in ReadWriteConsistencyControl eating CPU (load > 40) and no progress running YCSB on clean cluster startup HBASE-2785 TestScannerTimeout.test2772 is flaky + HBASE-2787 PE is confused about flushCommits IMPROVEMENTS HBASE-1760 Cleanup TODOs in HTable diff --git a/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java b/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java index 65aafc07a0df..3b756878409c 100644 --- a/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java +++ b/src/test/java/org/apache/hadoop/hbase/PerformanceEvaluation.java @@ -118,7 +118,7 @@ public class PerformanceEvaluation { private boolean nomapred = false; private int N = 1; private int R = ROWS_PER_GB; - private boolean flushCommits = false; + private boolean flushCommits = true; private boolean writeToWAL = true; private static final Path PERF_EVAL_DIR = new Path("performance_evaluation"); @@ -1250,7 +1250,7 @@ public int doCommandLine(final String[] args) { final String writeToWAL = "--writeToWAL="; if (cmd.startsWith(writeToWAL)) { - this.flushCommits = Boolean.parseBoolean(cmd.substring(writeToWAL.length())); + this.writeToWAL = Boolean.parseBoolean(cmd.substring(writeToWAL.length())); continue; }
8579b7b19462ffedc7bacd661e94189ebed6716c
Vala
posix: Add sync, fsync, and fdatasync bindings Fixes bug 590550.
a
https://github.com/GNOME/vala/
diff --git a/vapi/posix.vapi b/vapi/posix.vapi index e210311d01..3a8dd317fe 100644 --- a/vapi/posix.vapi +++ b/vapi/posix.vapi @@ -1569,6 +1569,12 @@ namespace Posix { [CCode (cheader_filename = "unistd.h")] public pid_t tcgetsid (int fd); + [CCode (cheader_filename = "unistd.h")] + public int fsync (int fd); + [CCode (cheader_filename = "unistd.h")] + public int fdatasync (int fd); + [CCode (cheader_filename = "unistd.h")] + public int sync (); [SimpleType] [CCode (cname = "cc_t", cheader_filename = "termios.h")]
54965e1da7b84207c5ab8613594ee73940e2bde2
arquillian$arquillian-graphene
ARQGRA-224: page fragments implementing WebElement interface delegate interface invocations to Root * A Page Fragment can be declated asbtract when implementing WebElement interface. Then all method invocations on such Page Fragment will be intercepted, and those which are from WebElement interface will be delegated to the Root of the page Fragment. * LocationEnricher - the creation of the page object was improved, now it is using the method from PageObjectEnricher to do so * Support for declaring Page Fragment as abstract class not added, cause it requires more changes in the code
a
https://github.com/arquillian/arquillian-graphene
diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/ftest/enricher/TestPageFragmentDelegatingToWebElement.java b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/ftest/enricher/TestPageFragmentDelegatingToWebElement.java new file mode 100644 index 000000000..1cd965a67 --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/ftest/enricher/TestPageFragmentDelegatingToWebElement.java @@ -0,0 +1,70 @@ +package org.jboss.arquillian.graphene.ftest.enricher; + +import static org.junit.Assert.assertEquals; + +import java.net.URL; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.drone.api.annotation.Drone; +import org.jboss.arquillian.graphene.ftest.Resources; +import org.jboss.arquillian.graphene.ftest.enricher.page.fragment.PageFragmentImplementingWebElement; +import org.jboss.arquillian.graphene.spi.annotations.InitialPage; +import org.jboss.arquillian.graphene.spi.annotations.Location; +import org.jboss.arquillian.graphene.spi.annotations.Page; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.FindBy; + +@RunWith(Arquillian.class) +@RunAsClient +public class TestPageFragmentDelegatingToWebElement { + + @Drone + private WebDriver browser; + + @ArquillianResource + private URL contextRoot; + + @Page + private TestPage page; + + private static final String pageLocation = "org/jboss/arquillian/graphene/ftest/enricher/delegating-pagefragment.html"; + + @Deployment + public static WebArchive createTestArchive() { + return Resources.inCurrentPackage().find("delegating-pagefragment.html").buildWar("deployment.war"); + } + + @Test + public void testPageFragmentMethodIsDelegatingCorrectly() { + browser.get(contextRoot + pageLocation); + testPage(page); + } + + @Test + public void testPageFragmentFromInitialPageIsDelegatingCorrectly(@InitialPage TestPage testedPage) { + testPage(testedPage); + } + + private void testPage(TestPage testedPage) { + String expectedText = "test"; + testedPage.getInputFragment().sendKeys(expectedText); + assertEquals(expectedText, testedPage.getInputFragment().getInputText()); + assertEquals("foo-bar", testedPage.getInputFragment().getStyleClass()); + } + + @Location("resource://" + pageLocation) + public class TestPage { + @FindBy(tagName = "input") + private PageFragmentImplementingWebElement inputFragment; + + public PageFragmentImplementingWebElement getInputFragment() { + return inputFragment; + } + } +} diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/ftest/enricher/page/fragment/PageFragmentImplementingWebElement.java b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/ftest/enricher/page/fragment/PageFragmentImplementingWebElement.java new file mode 100644 index 000000000..ec0479b4c --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/ftest/enricher/page/fragment/PageFragmentImplementingWebElement.java @@ -0,0 +1,18 @@ +package org.jboss.arquillian.graphene.ftest.enricher.page.fragment; + +import org.jboss.arquillian.graphene.spi.annotations.Root; +import org.openqa.selenium.WebElement; + +public abstract class PageFragmentImplementingWebElement implements WebElement { + + @Root + private WebElement input; + + public String getInputText() { + return input.getAttribute("value"); + } + + public String getStyleClass() { + return input.getAttribute("class"); + } +} diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/resources/org/jboss/arquillian/graphene/ftest/enricher/delegating-pagefragment.html b/graphene-webdriver/graphene-webdriver-ftest/src/test/resources/org/jboss/arquillian/graphene/ftest/enricher/delegating-pagefragment.html new file mode 100644 index 000000000..d86a4563d --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/resources/org/jboss/arquillian/graphene/ftest/enricher/delegating-pagefragment.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html> +<head> +<style type="text/css"> +.foo-bar { + width: 200px; + height: 120px; +} +</style> +</head> +<body> + <input class="foo-bar"/> +</body> +</html> \ No newline at end of file diff --git a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/ClassImposterizer.java b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/ClassImposterizer.java new file mode 100644 index 000000000..347a9de5b --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/ClassImposterizer.java @@ -0,0 +1,12 @@ +package org.jboss.arquillian.graphene.enricher; + +import net.sf.cglib.proxy.MethodInterceptor; + +class ClassImposterizer extends org.jboss.arquillian.graphene.cglib.ClassImposterizer { + + static final ClassImposterizer INSTANCE = new ClassImposterizer(); + + <T> T imposterise(MethodInterceptor interceptor, Class<T> mockedType, Class<?>... ancillaryTypes) { + return INSTANCE.imposteriseProtected(interceptor, mockedType, ancillaryTypes); + } +} diff --git a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/LocationEnricher.java b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/LocationEnricher.java index d8ca32ae1..ab0717b03 100644 --- a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/LocationEnricher.java +++ b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/LocationEnricher.java @@ -23,7 +23,6 @@ public class LocationEnricher implements TestEnricher { private static ThreadLocal<URL> contextRootStore = new ThreadLocal<URL>(); - private static String RESOURCE_PREFIX = "resource://"; @Inject private Instance<ServiceLoader> serviceLoader; @@ -42,11 +41,10 @@ public Object[] resolve(Method method) { return new Object[method.getParameterTypes().length]; } Class<?> qualifier = ReflectionHelper.getQualifier(method.getParameterAnnotations()[indexOfInitialPage]); - WebDriver browser = GrapheneContext.getContextFor(qualifier).getWebDriver(); Class<?>[] parameterTypes = method.getParameterTypes(); Object[] result = new Object[method.getParameterTypes().length]; - result[indexOfInitialPage] = goTo(parameterTypes[indexOfInitialPage], browser); + result[indexOfInitialPage] = goTo(parameterTypes[indexOfInitialPage], qualifier); URL contextRoot = getContextRoot(method); contextRootStore.set(contextRoot); @@ -54,12 +52,12 @@ public Object[] resolve(Method method) { return result; } - public <T> T goTo(Class<T> pageObject, WebDriver browser) { + public <T> T goTo(Class<T> pageObject, Class<?> browserQualifier) { T result = null; + GrapheneContext grapheneContext = GrapheneContext.getContextFor(browserQualifier); + WebDriver browser = grapheneContext.getWebDriver(); try { - T initializedPage = (T) pageObject.newInstance(); - AbstractSearchContextEnricher.enrichRecursively(browser, initializedPage); - result = initializedPage; + result = PageObjectEnricher.setupPage(grapheneContext, browser, pageObject); } catch (Exception e) { throw new GrapheneTestEnricherException("Error while initializing: " + pageObject, e); } @@ -67,19 +65,15 @@ public <T> T goTo(Class<T> pageObject, WebDriver browser) { return result; } - public <T> T goTo(Class<T> pageObject, Class<?> browserQualifier) { - WebDriver browser = GrapheneContext.getContextFor(browserQualifier).getWebDriver(); - return goTo(pageObject, browser); - } - private void handleLocationOf(Class<?> pageObjectClass, WebDriver browser) { Location location = pageObjectClass.getAnnotation(Location.class); if (location == null) { throw new IllegalArgumentException( - String.format( - "The page object '%s' that you are navigating to using either Graphene.goTo(<page_object>) or @InitialPage isn't annotated with @Location", - pageObjectClass.getSimpleName())); + String + .format( + "The page object '%s' that you are navigating to using either Graphene.goTo(<page_object>) or @InitialPage isn't annotated with @Location", + pageObjectClass.getSimpleName())); } try { @@ -87,7 +81,7 @@ private void handleLocationOf(Class<?> pageObjectClass, WebDriver browser) { browser.get(url.toExternalForm()); } catch (MalformedURLException e) { throw new IllegalArgumentException(String.format("Location '%s' specified on %s is not valid URL", - location.value(), pageObjectClass.getSimpleName())); + location.value(), pageObjectClass.getSimpleName())); } } @@ -102,7 +96,8 @@ private URL getURLFromLocation(Location location) throws MalformedURLException { if (contextRoot != null) { return new URL(contextRoot, location.value()); } else { - throw new IllegalStateException(String.format("The location %s is not valid URI and no contextRoot was discovered to treat it as relative URL", location)); + throw new IllegalStateException(String.format( + "The location %s is not valid URI and no contextRoot was discovered to treat it as relative URL", location)); } } @@ -113,7 +108,8 @@ private URL getURLFromLocation(Location location) throws MalformedURLException { } URL url = LocationEnricher.class.getClassLoader().getResource(resourceName); if (url == null) { - throw new IllegalArgumentException(String.format("Resource '%s' specified by %s was not found", resourceName, location)); + throw new IllegalArgumentException(String.format("Resource '%s' specified by %s was not found", resourceName, + location)); } return url; } @@ -131,7 +127,7 @@ private URL getURLFromLocation(Location location) throws MalformedURLException { /** * Returns the index of the first parameter which contains the <code>annotation</code> - * + * * @param annotation * @param method * @return diff --git a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentEnricher.java b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentEnricher.java index 27fc1bf76..d63f9b292 100644 --- a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentEnricher.java +++ b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentEnricher.java @@ -23,9 +23,15 @@ package org.jboss.arquillian.graphene.enricher; import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; + +import net.sf.cglib.proxy.MethodInterceptor; +import net.sf.cglib.proxy.MethodProxy; + import org.jboss.arquillian.core.api.Instance; import org.jboss.arquillian.core.api.annotation.Inject; @@ -44,9 +50,8 @@ import org.openqa.selenium.support.FindBy; /** - * Enricher injecting page fragments ({@link FindBy} annotation is used) to the - * fields of the given object. - * + * Enricher injecting page fragments ({@link FindBy} annotation is used) to the fields of the given object. + * * @author <a href="mailto:[email protected]">Juraj Huska</a> * @author <a href="mailto:[email protected]">Jan Papousek</a> */ @@ -67,7 +72,8 @@ public PageFragmentEnricher(Instance<GrapheneConfiguration> configuration) { public void enrich(final SearchContext searchContext, Object target) { List<Field> fields = FindByUtilities.getListOfFieldsAnnotatedWithFindBys(target); for (Field field : fields) { - GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext).getContext(); + GrapheneContext grapheneContext = searchContext == null ? null : ((GrapheneProxyInstance) searchContext) + .getContext(); final SearchContext localSearchContext; if (grapheneContext == null) { grapheneContext = GrapheneContext.getContextFor(ReflectionHelper.getQualifier(field.getAnnotations())); @@ -93,8 +99,7 @@ public void enrich(final SearchContext searchContext, Object target) { protected final boolean isPageFragmentClass(Class<?> clazz) { // check whether it isn't interface or final class - if (Modifier.isInterface(clazz.getModifiers()) || Modifier.isFinal(clazz.getModifiers()) - || Modifier.isAbstract(clazz.getModifiers())) { + if (Modifier.isInterface(clazz.getModifiers()) || Modifier.isFinal(clazz.getModifiers())) { return false; } @@ -125,15 +130,20 @@ public Object getTarget() { return result; } - public static <T> T createPageFragment(Class<T> clazz, WebElement root) { + public static <T> T createPageFragment(Class<T> clazz, final WebElement root) { try { GrapheneContext grapheneContext = ((GrapheneProxyInstance) root).getContext(); - T pageFragment = instantiate(clazz); + T pageFragment = null; + if (isAboutToDelegateToWebElement(clazz)) { + pageFragment = createProxyDelegatingToRoot(root, clazz); + } else { + pageFragment = instantiate(clazz); + } List<Field> roots = ReflectionHelper.getFieldsWithAnnotation(clazz, Root.class); if (roots.size() > 1) { throw new PageFragmentInitializationException("The Page Fragment " + NEW_LINE + pageFragment.getClass() - + NEW_LINE + " can not have more than one field annotated with Root annotation!" - + "Your fields with @Root annotation: " + roots + NEW_LINE); + + NEW_LINE + " can not have more than one field annotated with Root annotation!" + + "Your fields with @Root annotation: " + roots + NEW_LINE); } if (roots.size() == 1) { setValue(roots.get(0), pageFragment, root); @@ -144,22 +154,41 @@ public static <T> T createPageFragment(Class<T> clazz, WebElement root) { return proxy; } catch (NoSuchMethodException ex) { throw new PageFragmentInitializationException(" Check whether declared Page Fragment has no argument constructor!", - ex); + ex); } catch (IllegalAccessException ex) { throw new PageFragmentInitializationException( - " Check whether declared Page Fragment has public no argument constructor!", ex); + " Check whether declared Page Fragment has public no argument constructor!", ex); } catch (InstantiationException ex) { throw new PageFragmentInitializationException( - " Check whether you did not declare Page Fragment with abstract type!", ex); + " Check whether you did not declare Page Fragment with abstract type!", ex); } catch (Exception ex) { throw new PageFragmentInitializationException(ex); } } + private static boolean isAboutToDelegateToWebElement(Class<?> clazz) { + return Arrays.asList(clazz.getInterfaces()).contains(WebElement.class); + } + + private static <T> T createProxyDelegatingToRoot(final WebElement root, Class<T> clazz) { + return ClassImposterizer.INSTANCE.imposterise(new MethodInterceptor() { + + @Override + public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { + List<Method> webElementMethods = Arrays.asList(WebElement.class.getMethods()); + if (webElementMethods.contains(method)) { + return method.invoke(root, args); + } else { + return proxy.invokeSuper(obj, args); + } + } + }, clazz, WebElement.class); + } + protected final void setupPageFragmentList(SearchContext searchContext, Object target, Field field) - throws ClassNotFoundException { + throws ClassNotFoundException { GrapheneContext grapheneContext = ((GrapheneProxyInstance) searchContext).getContext(); - //the by retrieved in this way is never null, by default it is ByIdOrName using field name + // the by retrieved in this way is never null, by default it is ByIdOrName using field name By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy()); List<?> pageFragments = createPageFragmentList(getListType(field), searchContext, rootBy); setValue(field, target, pageFragments); @@ -167,7 +196,7 @@ protected final void setupPageFragmentList(SearchContext searchContext, Object t protected final void setupPageFragment(SearchContext searchContext, Object target, Field field) { GrapheneContext grapheneContext = ((GrapheneProxyInstance) searchContext).getContext(); - //the by retrieved in this way is never null, by default it is ByIdOrName using field name + // the by retrieved in this way is never null, by default it is ByIdOrName using field name By rootBy = FindByUtilities.getCorrectBy(field, configuration.get().getDefaultElementLocatingStrategy()); WebElement root = WebElementUtils.findElementLazily(rootBy, searchContext); Object pageFragment = createPageFragment(field.getType(), root); diff --git a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageObjectEnricher.java b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageObjectEnricher.java index d0c48e43b..9698650fd 100644 --- a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageObjectEnricher.java +++ b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageObjectEnricher.java @@ -89,7 +89,7 @@ public void enrich(final SearchContext searchContext, Object target) { } } - protected <P> P setupPage(GrapheneContext context, SearchContext searchContext, Class<?> pageClass) throws Exception{ + public static <P> P setupPage(GrapheneContext context, SearchContext searchContext, Class<?> pageClass) throws Exception{ P page = (P) instantiate(pageClass); P proxy = GrapheneProxy.getProxyForHandler(GrapheneProxyHandler.forTarget(context, page), pageClass); enrichRecursively(searchContext, page); diff --git a/graphene-webdriver/graphene-webdriver-impl/src/test/java/org/jboss/arquillian/graphene/enricher/TestPageFragmentEnricher.java b/graphene-webdriver/graphene-webdriver-impl/src/test/java/org/jboss/arquillian/graphene/enricher/TestPageFragmentEnricher.java index 7b6eb798e..5657231e8 100644 --- a/graphene-webdriver/graphene-webdriver-impl/src/test/java/org/jboss/arquillian/graphene/enricher/TestPageFragmentEnricher.java +++ b/graphene-webdriver/graphene-webdriver-impl/src/test/java/org/jboss/arquillian/graphene/enricher/TestPageFragmentEnricher.java @@ -42,22 +42,21 @@ public void testMissingNoArgConstructor() { Assert.assertNull(target.pageFragment); } - @Test public void testTooManyRoots() { thrown.expect(PageFragmentInitializationException.class); getGrapheneEnricher().enrich(new TooManyRootsTest()); } - @Test + @Test(expected = PageFragmentInitializationException.class) public void testAbstractType() { AbstractTypeTest target = new AbstractTypeTest(); getGrapheneEnricher().enrich(target); - Assert.assertNull(target.pageFragment); + Assert.assertNotNull(target.pageFragment); } public static class NoArgConstructorTest { - @FindBy(id="blah") + @FindBy(id = "blah") private WrongPageFragmentMissingNoArgConstructor pageFragment; }
b6fcb0ba231e39b85e71c61ed5521fc67a2f98e8
drools
BZ975922 - GRE constraint operator list box- problems when re-opening file--
c
https://github.com/kiegroup/drools
diff --git a/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java b/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java index fdaca19222e..c6b56e247ca 100644 --- a/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java +++ b/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java @@ -1730,8 +1730,8 @@ public RuleModel unmarshalUsingDSL( final String str, dmo ); } - private ExpandedDRLInfo parseDSLs( ExpandedDRLInfo expandedDRLInfo, - String[] dsls ) { + private ExpandedDRLInfo parseDSLs( final ExpandedDRLInfo expandedDRLInfo, + final String[] dsls ) { for ( String dsl : dsls ) { for ( String line : dsl.split( "\n" ) ) { String dslPattern = line.trim(); @@ -1751,7 +1751,7 @@ private ExpandedDRLInfo parseDSLs( ExpandedDRLInfo expandedDRLInfo, return expandedDRLInfo; } - private String removeDslTopics( String line ) { + private String removeDslTopics( final String line ) { int lastClosedSquare = -1; boolean lookForOpen = true; for ( int i = 0; i < line.length(); i++ ) { @@ -1772,12 +1772,13 @@ private String removeDslTopics( String line ) { return line.substring( lastClosedSquare + 1 ); } - private String extractDslPattern( String line ) { - return line.substring( 0, line.indexOf( '=' ) ).trim(); + private String extractDslPattern( final String line ) { + return line.substring( 0, + line.indexOf( '=' ) ).trim(); } - private RuleModel getRuleModel( ExpandedDRLInfo expandedDRLInfo, - PackageDataModelOracle dmo ) { + private RuleModel getRuleModel( final ExpandedDRLInfo expandedDRLInfo, + final PackageDataModelOracle dmo ) { //De-serialize model RuleDescr ruleDescr = parseDrl( expandedDRLInfo ); RuleModel model = new RuleModel(); @@ -1787,7 +1788,8 @@ private RuleModel getRuleModel( ExpandedDRLInfo expandedDRLInfo, Map<String, AnnotationDescr> annotations = ruleDescr.getAnnotations(); if ( annotations != null ) { for ( AnnotationDescr annotation : annotations.values() ) { - model.addMetadata( new RuleMetadata( annotation.getName(), annotation.getValuesAsString() ) ); + model.addMetadata( new RuleMetadata( annotation.getName(), + annotation.getValuesAsString() ) ); } } @@ -1803,7 +1805,10 @@ private RuleModel getRuleModel( ExpandedDRLInfo expandedDRLInfo, boolean isJavaDialect = parseAttributes( model, ruleDescr.getAttributes() ); - Map<String, String> boundParams = parseLhs( model, ruleDescr.getLhs(), expandedDRLInfo, dmo ); + Map<String, String> boundParams = parseLhs( model, + ruleDescr.getLhs(), + expandedDRLInfo, + dmo ); parseRhs( model, expandedDRLInfo.consequence != null ? expandedDRLInfo.consequence : (String) ruleDescr.getConsequence(), isJavaDialect, @@ -1813,8 +1818,8 @@ private RuleModel getRuleModel( ExpandedDRLInfo expandedDRLInfo, return model; } - private ExpandedDRLInfo preprocessDRL( String str, - boolean hasDsl ) { + private ExpandedDRLInfo preprocessDRL( final String str, + final boolean hasDsl ) { StringBuilder drl = new StringBuilder(); String thenLine = null; List<String> lhsStatements = new ArrayList<String>(); @@ -1869,11 +1874,11 @@ private int parenthesisBalance( String str ) { return balance; } - private ExpandedDRLInfo createExpandedDRLInfo( boolean hasDsl, - StringBuilder drl, - String thenLine, - List<String> lhsStatements, - List<String> rhsStatements ) { + private ExpandedDRLInfo createExpandedDRLInfo( final boolean hasDsl, + final StringBuilder drl, + final String thenLine, + final List<String> lhsStatements, + final List<String> rhsStatements ) { if ( !hasDsl ) { return processFreeFormStatement( drl, thenLine, @@ -1906,13 +1911,15 @@ private ExpandedDRLInfo createExpandedDRLInfo( boolean hasDsl, lineCounter++; String trimmed = statement.trim(); if ( trimmed.endsWith( "end" ) ) { - trimmed = trimmed.substring( 0, trimmed.length() - 3 ).trim(); + trimmed = trimmed.substring( 0, + trimmed.length() - 3 ).trim(); } if ( trimmed.length() > 0 ) { if ( hasDsl && trimmed.startsWith( ">" ) ) { drl.append( trimmed.substring( 1 ) ).append( "\n" ); } else { - expandedDRLInfo.dslStatementsInRhs.put( lineCounter, trimmed ); + expandedDRLInfo.dslStatementsInRhs.put( lineCounter, + trimmed ); } } } @@ -1922,10 +1929,10 @@ private ExpandedDRLInfo createExpandedDRLInfo( boolean hasDsl, return expandedDRLInfo; } - private ExpandedDRLInfo processFreeFormStatement( StringBuilder drl, - String thenLine, - List<String> lhsStatements, - List<String> rhsStatements ) { + private ExpandedDRLInfo processFreeFormStatement( final StringBuilder drl, + final String thenLine, + final List<String> lhsStatements, + final List<String> rhsStatements ) { ExpandedDRLInfo expandedDRLInfo = new ExpandedDRLInfo( false ); int lineCounter = -1; @@ -1959,7 +1966,7 @@ private ExpandedDRLInfo processFreeFormStatement( StringBuilder drl, return expandedDRLInfo; } - private boolean isValidLHSStatement( String lhs ) { + private boolean isValidLHSStatement( final String lhs ) { // TODO: How to identify a non valid (free form) lhs statement? return ( lhs.indexOf( '(' ) >= 0 || lhs.indexOf( ':' ) >= 0 ) && lhs.indexOf( "//" ) == -1; } @@ -1982,7 +1989,7 @@ private static class ExpandedDRLInfo { private Set<String> globals = new HashSet<String>(); - private ExpandedDRLInfo( boolean hasDsl ) { + private ExpandedDRLInfo( final boolean hasDsl ) { this.hasDsl = hasDsl; dslStatementsInLhs = new HashMap<Integer, String>(); dslStatementsInRhs = new HashMap<Integer, String>(); @@ -1991,12 +1998,12 @@ private ExpandedDRLInfo( boolean hasDsl ) { rhsDslPatterns = new ArrayList<String>(); } - public boolean hasGlobal( String name ) { + public boolean hasGlobal( final String name ) { return globals.contains( name ); } - public ExpandedDRLInfo registerGlobals( PackageDataModelOracle dmo, - List<String> globalStatements ) { + public ExpandedDRLInfo registerGlobals( final PackageDataModelOracle dmo, + final List<String> globalStatements ) { if ( globalStatements != null ) { for ( String globalStatement : globalStatements ) { String identifier = getIdentifier( globalStatement ); @@ -2023,12 +2030,13 @@ private String getIdentifier( String globalStatement ) { } String identifier = globalStatement.substring( lastSpace + 1 ); if ( identifier.endsWith( ";" ) ) { - identifier = identifier.substring( 0, identifier.length() - 1 ); + identifier = identifier.substring( 0, + identifier.length() - 1 ); } return identifier; } - public ExpandedDRLInfo registerGlobalDescrs( List<GlobalDescr> globalDescrs ) { + public ExpandedDRLInfo registerGlobalDescrs( final List<GlobalDescr> globalDescrs ) { if ( globalDescrs != null ) { for ( GlobalDescr globalDescr : globalDescrs ) { globals.add( globalDescr.getIdentifier() ); @@ -2038,7 +2046,7 @@ public ExpandedDRLInfo registerGlobalDescrs( List<GlobalDescr> globalDescrs ) { } } - private RuleDescr parseDrl( ExpandedDRLInfo expandedDRLInfo ) { + private RuleDescr parseDrl( final ExpandedDRLInfo expandedDRLInfo ) { DrlParser drlParser = new DrlParser(); PackageDescr packageDescr; try { @@ -2050,13 +2058,14 @@ private RuleDescr parseDrl( ExpandedDRLInfo expandedDRLInfo ) { return packageDescr.getRules().get( 0 ); } - private boolean parseAttributes( RuleModel m, - Map<String, AttributeDescr> attributes ) { + private boolean parseAttributes( final RuleModel m, + final Map<String, AttributeDescr> attributes ) { boolean isJavaDialect = false; for ( Map.Entry<String, AttributeDescr> entry : attributes.entrySet() ) { String name = entry.getKey(); String value = normalizeAttributeValue( entry.getValue().getValue().trim() ); - RuleAttribute ruleAttribute = new RuleAttribute( name, value ); + RuleAttribute ruleAttribute = new RuleAttribute( name, + value ); m.addAttribute( ruleAttribute ); isJavaDialect |= name.equals( "dialect" ) && value.equals( "java" ); } @@ -2086,47 +2095,59 @@ private String stripQuotes( String value ) { return value; } - private Map<String, String> parseLhs( RuleModel m, - AndDescr lhs, - ExpandedDRLInfo expandedDRLInfo, - PackageDataModelOracle dmo ) { + private Map<String, String> parseLhs( final RuleModel m, + final AndDescr lhs, + final ExpandedDRLInfo expandedDRLInfo, + final PackageDataModelOracle dmo ) { Map<String, String> boundParams = new HashMap<String, String>(); int lineCounter = -1; for ( BaseDescr descr : lhs.getDescrs() ) { - lineCounter = parseNonDrlInLhs( m, expandedDRLInfo, lineCounter ); - IPattern pattern = parseBaseDescr( m, descr, boundParams, dmo ); + lineCounter = parseNonDrlInLhs( m, + expandedDRLInfo, + lineCounter ); + IPattern pattern = parseBaseDescr( m, + descr, + boundParams, + dmo ); if ( pattern != null ) { m.addLhsItem( pattern ); } } - parseNonDrlInLhs( m, expandedDRLInfo, lineCounter ); + parseNonDrlInLhs( m, + expandedDRLInfo, + lineCounter ); return boundParams; } - private int parseNonDrlInLhs( RuleModel m, - ExpandedDRLInfo expandedDRLInfo, + private int parseNonDrlInLhs( final RuleModel m, + final ExpandedDRLInfo expandedDRLInfo, int lineCounter ) { lineCounter++; - lineCounter = parseDslInLhs( m, expandedDRLInfo, lineCounter ); - lineCounter = parseFreeForm( m, expandedDRLInfo, lineCounter ); + lineCounter = parseDslInLhs( m, + expandedDRLInfo, + lineCounter ); + lineCounter = parseFreeForm( m, + expandedDRLInfo, + lineCounter ); return lineCounter; } - private int parseDslInLhs( RuleModel m, - ExpandedDRLInfo expandedDRLInfo, + private int parseDslInLhs( final RuleModel m, + final ExpandedDRLInfo expandedDRLInfo, int lineCounter ) { if ( expandedDRLInfo.hasDsl ) { String dslLine = expandedDRLInfo.dslStatementsInLhs.get( lineCounter ); while ( dslLine != null ) { - m.addLhsItem( toDSLSentence( expandedDRLInfo.lhsDslPatterns, dslLine ) ); + m.addLhsItem( toDSLSentence( expandedDRLInfo.lhsDslPatterns, + dslLine ) ); dslLine = expandedDRLInfo.dslStatementsInLhs.get( ++lineCounter ); } } return lineCounter; } - private int parseFreeForm( RuleModel m, - ExpandedDRLInfo expandedDRLInfo, + private int parseFreeForm( final RuleModel m, + final ExpandedDRLInfo expandedDRLInfo, int lineCounter ) { String freeForm = expandedDRLInfo.freeFormStatementsInLhs.get( lineCounter ); while ( freeForm != null ) { @@ -2138,39 +2159,55 @@ private int parseFreeForm( RuleModel m, return lineCounter; } - private IPattern parseBaseDescr( RuleModel m, - BaseDescr descr, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + private IPattern parseBaseDescr( final RuleModel m, + final BaseDescr descr, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo ) { if ( descr instanceof PatternDescr ) { - return parsePatternDescr( m, (PatternDescr) descr, boundParams, dmo ); + return parsePatternDescr( m, + (PatternDescr) descr, + boundParams, + dmo ); } else if ( descr instanceof AndDescr ) { AndDescr andDescr = (AndDescr) descr; - return parseBaseDescr( m, andDescr.getDescrs().get( 0 ), boundParams, dmo ); + return parseBaseDescr( m, + andDescr.getDescrs().get( 0 ), + boundParams, + dmo ); } else if ( descr instanceof EvalDescr ) { FreeFormLine freeFormLine = new FreeFormLine(); freeFormLine.setText( "eval( " + ( (EvalDescr) descr ).getContent() + " )" ); return freeFormLine; } else if ( descr instanceof ConditionalElementDescr ) { - return parseExistentialElementDescr( m, (ConditionalElementDescr) descr, boundParams, dmo ); + return parseExistentialElementDescr( m, + (ConditionalElementDescr) descr, + boundParams, + dmo ); } return null; } - private IFactPattern parsePatternDescr( RuleModel m, - PatternDescr pattern, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + private IFactPattern parsePatternDescr( final RuleModel m, + final PatternDescr pattern, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo ) { if ( pattern.getSource() != null ) { - return parsePatternSource( m, pattern, pattern.getSource(), boundParams, dmo ); - } - return getFactPattern( m, pattern, boundParams, dmo ); - } - - private FactPattern getFactPattern( RuleModel m, - PatternDescr pattern, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + return parsePatternSource( m, + pattern, + pattern.getSource(), + boundParams, + dmo ); + } + return getFactPattern( m, + pattern, + boundParams, + dmo ); + } + + private FactPattern getFactPattern( final RuleModel m, + final PatternDescr pattern, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo ) { String type = pattern.getObjectType(); FactPattern factPattern = new FactPattern( getSimpleFactType( type, dmo ) ); @@ -2206,15 +2243,18 @@ private FactPattern getFactPattern( RuleModel m, return factPattern; } - private IFactPattern parsePatternSource( RuleModel m, - PatternDescr pattern, - PatternSourceDescr patternSource, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + private IFactPattern parsePatternSource( final RuleModel m, + final PatternDescr pattern, + final PatternSourceDescr patternSource, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo ) { if ( patternSource instanceof AccumulateDescr ) { AccumulateDescr accumulate = (AccumulateDescr) patternSource; FromAccumulateCompositeFactPattern fac = new FromAccumulateCompositeFactPattern(); - fac.setSourcePattern( parseBaseDescr( m, accumulate.getInput(), boundParams, dmo ) ); + fac.setSourcePattern( parseBaseDescr( m, + accumulate.getInput(), + boundParams, + dmo ) ); FactPattern factPattern = new FactPattern( pattern.getObjectType() ); factPattern.setBoundName( pattern.getIdentifier() ); @@ -2286,8 +2326,12 @@ private IFactPattern parsePatternSource( RuleModel m, String sourcePart = splitSource[ i ]; if ( i == 0 ) { String type = boundParams.get( sourcePart ); - expression.appendPart( new ExpressionVariable( sourcePart, type, DataType.TYPE_NUMERIC ) ); - fields = findFields( dmo, m, type ); + expression.appendPart( new ExpressionVariable( sourcePart, + type, + DataType.TYPE_NUMERIC ) ); + fields = findFields( m, + dmo, + type ); } else { ModelField modelField = null; for ( ModelField field : fields ) { @@ -2319,8 +2363,8 @@ private IFactPattern parsePatternSource( RuleModel m, expression.appendPart( new ExpressionField( sourcePart, modelField.getClassName(), modelField.getType() ) ); - fields = findFields( dmo, - m, + fields = findFields( m, + dmo, modelField.getClassName() ); } } @@ -2331,49 +2375,63 @@ private IFactPattern parsePatternSource( RuleModel m, throw new RuntimeException( "Unknown pattern source " + patternSource ); } - private CompositeFactPattern parseExistentialElementDescr( RuleModel m, - ConditionalElementDescr conditionalDescr, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + private CompositeFactPattern parseExistentialElementDescr( final RuleModel m, + final ConditionalElementDescr conditionalDescr, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo ) { CompositeFactPattern comp = conditionalDescr instanceof NotDescr ? new CompositeFactPattern( CompositeFactPattern.COMPOSITE_TYPE_NOT ) : conditionalDescr instanceof OrDescr ? new CompositeFactPattern( CompositeFactPattern.COMPOSITE_TYPE_OR ) : new CompositeFactPattern( CompositeFactPattern.COMPOSITE_TYPE_EXISTS ); - addPatternToComposite( m, conditionalDescr, comp, boundParams, dmo ); + addPatternToComposite( m, + conditionalDescr, + comp, + boundParams, + dmo ); IFactPattern[] patterns = comp.getPatterns(); return patterns != null && patterns.length > 0 ? comp : null; } - private void addPatternToComposite( RuleModel m, - ConditionalElementDescr conditionalDescr, - CompositeFactPattern comp, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + private void addPatternToComposite( final RuleModel m, + final ConditionalElementDescr conditionalDescr, + final CompositeFactPattern comp, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo ) { for ( Object descr : conditionalDescr.getDescrs() ) { if ( descr instanceof PatternDescr ) { - comp.addFactPattern( parsePatternDescr( m, (PatternDescr) descr, boundParams, dmo ) ); + comp.addFactPattern( parsePatternDescr( m, + (PatternDescr) descr, + boundParams, + dmo ) ); } else if ( descr instanceof ConditionalElementDescr ) { - addPatternToComposite( m, (ConditionalElementDescr) descr, comp, boundParams, dmo ); + addPatternToComposite( m, + (ConditionalElementDescr) descr, + comp, + boundParams, + dmo ); } } } - private void parseConstraint( RuleModel m, - FactPattern factPattern, - ConditionalElementDescr constraint, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + private void parseConstraint( final RuleModel m, + final FactPattern factPattern, + final ConditionalElementDescr constraint, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo ) { for ( BaseDescr descr : constraint.getDescrs() ) { if ( descr instanceof ExprConstraintDescr ) { ExprConstraintDescr exprConstraint = (ExprConstraintDescr) descr; - Expr expr = parseExpr( exprConstraint.getExpression(), boundParams, dmo ); - factPattern.addConstraint( expr.asFieldConstraint( m, factPattern ) ); + Expr expr = parseExpr( exprConstraint.getExpression(), + boundParams, + dmo ); + factPattern.addConstraint( expr.asFieldConstraint( m, + factPattern ) ); } } } - private static String findOperator( String expr ) { + private static String findOperator( final String expr ) { final Set<String> potentialOperators = new HashSet<String>(); for ( Operator op : Operator.getAllOperators() ) { String opString = op.getOperatorString(); @@ -2411,8 +2469,8 @@ private static String findOperator( String expr ) { return null; } - private static boolean isInQuote( String expr, - int pos ) { + private static boolean isInQuote( final String expr, + final int pos ) { boolean isInQuote = false; for ( int i = pos - 1; i >= 0; i-- ) { if ( expr.charAt( i ) == '"' ) { @@ -2424,7 +2482,7 @@ private static boolean isInQuote( String expr, private static final String[] NULL_OPERATORS = new String[]{ "== null", "!= null" }; - private static String findNullOrNotNullOperator( String expr ) { + private static String findNullOrNotNullOperator( final String expr ) { for ( String op : NULL_OPERATORS ) { if ( expr.contains( op ) ) { return op; @@ -2433,12 +2491,12 @@ private static String findNullOrNotNullOperator( String expr ) { return null; } - private void parseRhs( RuleModel m, - String rhs, - boolean isJavaDialect, - Map<String, String> boundParams, - ExpandedDRLInfo expandedDRLInfo, - PackageDataModelOracle dmo ) { + private void parseRhs( final RuleModel m, + final String rhs, + final boolean isJavaDialect, + final Map<String, String> boundParams, + final ExpandedDRLInfo expandedDRLInfo, + final PackageDataModelOracle dmo ) { PortableWorkDefinition pwd = null; Map<String, List<String>> setStatements = new HashMap<String, List<String>>(); Map<String, Integer> setStatementsPosition = new HashMap<String, Integer>(); @@ -2454,7 +2512,8 @@ private void parseRhs( RuleModel m, if ( expandedDRLInfo.hasDsl ) { String dslLine = expandedDRLInfo.dslStatementsInRhs.get( lineCounter ); while ( dslLine != null ) { - m.addRhsItem( toDSLSentence( expandedDRLInfo.rhsDslPatterns, dslLine ) ); + m.addRhsItem( toDSLSentence( expandedDRLInfo.rhsDslPatterns, + dslLine ) ); dslLine = expandedDRLInfo.dslStatementsInRhs.get( ++lineCounter ); } } @@ -2463,19 +2522,20 @@ private void parseRhs( RuleModel m, int modifyBlockEnd = line.lastIndexOf( '}' ); if ( modifiers == null ) { modifiers = modifyBlockEnd > 0 ? - line.substring( line.indexOf( '{' ) + 1, modifyBlockEnd ).trim() : + line.substring( line.indexOf( '{' ) + 1, + modifyBlockEnd ).trim() : line.substring( line.indexOf( '{' ) + 1 ).trim(); } else if ( modifyBlockEnd != 0 ) { modifiers += modifyBlockEnd > 0 ? - line.substring( 0, modifyBlockEnd ).trim() : + line.substring( 0, + modifyBlockEnd ).trim() : line; } if ( modifyBlockEnd >= 0 ) { ActionUpdateField action = new ActionUpdateField(); action.setVariable( modifiedVariable ); m.addRhsItem( action ); - addModifiersToAction( modifiedVariable, - modifiers, + addModifiersToAction( modifiers, action, boundParams, dmo, @@ -2486,7 +2546,8 @@ private void parseRhs( RuleModel m, } } else if ( line.startsWith( "insertLogical" ) ) { String fact = unwrapParenthesis( line ); - String type = getStatementType( fact, factsType ); + String type = getStatementType( fact, + factsType ); if ( type != null ) { ActionInsertLogicalFact action = new ActionInsertLogicalFact( type ); m.addRhsItem( action ); @@ -2502,7 +2563,8 @@ private void parseRhs( RuleModel m, } } else if ( line.startsWith( "insert" ) ) { String fact = unwrapParenthesis( line ); - String type = getStatementType( fact, factsType ); + String type = getStatementType( fact, + factsType ); if ( type != null ) { ActionInsertFact action = new ActionInsertFact( type ); m.addRhsItem( action ); @@ -2532,19 +2594,21 @@ private void parseRhs( RuleModel m, } else if ( line.startsWith( "modify" ) ) { int modifyBlockEnd = line.lastIndexOf( '}' ); if ( modifyBlockEnd > 0 ) { - String variable = line.substring( line.indexOf( '(' ) + 1, line.indexOf( ')' ) ).trim(); + String variable = line.substring( line.indexOf( '(' ) + 1, + line.indexOf( ')' ) ).trim(); ActionUpdateField action = new ActionUpdateField(); action.setVariable( variable ); m.addRhsItem( action ); - addModifiersToAction( variable, - line.substring( line.indexOf( '{' ) + 1, modifyBlockEnd ).trim(), + addModifiersToAction( line.substring( line.indexOf( '{' ) + 1, + modifyBlockEnd ).trim(), action, boundParams, dmo, m.getImports(), isJavaDialect ); } else { - modifiedVariable = line.substring( line.indexOf( '(' ) + 1, line.indexOf( ')' ) ).trim(); + modifiedVariable = line.substring( line.indexOf( '(' ) + 1, + line.indexOf( ')' ) ).trim(); int modifyBlockStart = line.indexOf( '{' ); if ( modifyBlockStart > 0 ) { modifiers = line.substring( modifyBlockStart + 1 ).trim(); @@ -2563,35 +2627,49 @@ private void parseRhs( RuleModel m, String statement = line.substring( "wiWorkItem.getParameters().put".length() ); statement = unwrapParenthesis( statement ); int commaPos = statement.indexOf( ',' ); - String name = statement.substring( 0, commaPos ).trim(); + String name = statement.substring( 0, + commaPos ).trim(); String value = statement.substring( commaPos + 1 ).trim(); - pwd.addParameter( buildPortableParameterDefinition( name, value, boundParams ) ); + pwd.addParameter( buildPortableParameterDefinition( name, + value, + boundParams ) ); } else if ( line.startsWith( "wim.internalExecuteWorkItem" ) || line.startsWith( "wiWorkItem.setName" ) ) { // ignore } else { int dotPos = line.indexOf( '.' ); int argStart = line.indexOf( '(' ); if ( dotPos > 0 && argStart > dotPos ) { - String variable = line.substring( 0, dotPos ).trim(); + String variable = line.substring( 0, + dotPos ).trim(); if ( isJavaIdentifier( variable ) ) { - String methodName = line.substring( dotPos + 1, argStart ).trim(); + String methodName = line.substring( dotPos + 1, + argStart ).trim(); if ( isJavaIdentifier( methodName ) ) { if ( getSettedField( methodName ) != null ) { List<String> setters = setStatements.get( variable ); if ( setters == null ) { setters = new ArrayList<String>(); - setStatements.put( variable, setters ); + setStatements.put( variable, + setters ); } - setStatementsPosition.put( variable, lineCounter ); + setStatementsPosition.put( variable, + lineCounter ); setters.add( line ); } else if ( methodName.equals( "add" ) && expandedDRLInfo.hasGlobal( variable ) ) { - String factName = line.substring( argStart + 1, line.lastIndexOf( ')' ) ).trim(); + String factName = line.substring( argStart + 1, + line.lastIndexOf( ')' ) ).trim(); ActionGlobalCollectionAdd actionGlobalCollectionAdd = new ActionGlobalCollectionAdd(); actionGlobalCollectionAdd.setGlobalName( variable ); actionGlobalCollectionAdd.setFactName( factName ); m.addRhsItem( actionGlobalCollectionAdd ); } else { - m.addRhsItem( getActionCallMethod( m, isJavaDialect, boundParams, dmo, line, variable, methodName ) ); + m.addRhsItem( getActionCallMethod( m, + isJavaDialect, + boundParams, + dmo, + line, + variable, + methodName ) ); } continue; } @@ -2601,14 +2679,18 @@ private void parseRhs( RuleModel m, int eqPos = line.indexOf( '=' ); boolean addFreeFormLine = line.trim().length() > 0; if ( eqPos > 0 ) { - String field = line.substring( 0, eqPos ).trim(); + String field = line.substring( 0, + eqPos ).trim(); if ( "java.text.SimpleDateFormat sdf".equals( field ) || "org.drools.core.process.instance.WorkItemManager wim".equals( field ) ) { addFreeFormLine = false; } String[] split = field.split( " " ); if ( split.length == 2 ) { - factsType.put( split[ 1 ], split[ 0 ] ); - addFreeFormLine &= !isInsertedFact( lines, lineCounter, split[ 1 ] ); + factsType.put( split[ 1 ], + split[ 0 ] ); + addFreeFormLine &= !isInsertedFact( lines, + lineCounter, + split[ 1 ] ); } } if ( addFreeFormLine ) { @@ -2627,42 +2709,39 @@ private void parseRhs( RuleModel m, dmo, m.getImports(), isJavaDialect ); - m.addRhsItem( action, setStatementsPosition.get( entry.getKey() ) ); + m.addRhsItem( action, + setStatementsPosition.get( entry.getKey() ) ); } if ( expandedDRLInfo.hasDsl ) { String dslLine = expandedDRLInfo.dslStatementsInRhs.get( ++lineCounter ); while ( dslLine != null ) { - m.addRhsItem( toDSLSentence( expandedDRLInfo.rhsDslPatterns, dslLine ) ); + m.addRhsItem( toDSLSentence( expandedDRLInfo.rhsDslPatterns, + dslLine ) ); dslLine = expandedDRLInfo.dslStatementsInRhs.get( ++lineCounter ); } } } - private ActionCallMethod getActionCallMethod( - RuleModel model, - boolean isJavaDialect, - Map<String, String> boundParams, - PackageDataModelOracle dmo, - String line, - String variable, - String methodName ) { + private ActionCallMethod getActionCallMethod( final RuleModel model, + final boolean isJavaDialect, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo, + final String line, + final String variable, + final String methodName ) { - return new ActionCallMethodBuilder( - model, - dmo, - isJavaDialect, - boundParams - ).get( - variable, - methodName, - unwrapParenthesis( line ).split( "," ) - ); + return new ActionCallMethodBuilder( model, + dmo, + isJavaDialect, + boundParams ).get( variable, + methodName, + unwrapParenthesis( line ).split( "," ) ); } - private boolean isInsertedFact( String[] lines, - int lineCounter, - String fact ) { + private boolean isInsertedFact( final String[] lines, + final int lineCounter, + final String fact ) { for ( int i = lineCounter; i < lines.length; i++ ) { String line = lines[ i ].trim(); if ( line.startsWith( "insert" ) ) { @@ -2674,17 +2753,20 @@ private boolean isInsertedFact( String[] lines, return false; } - private DSLSentence toDSLSentence( List<String> dslPatterns, - String dslLine ) { + private DSLSentence toDSLSentence( final List<String> dslPatterns, + final String dslLine ) { DSLSentence dslSentence = new DSLSentence(); for ( String dslPattern : dslPatterns ) { // Dollar breaks the matcher, need to escape them. - dslPattern = dslPattern.replace( "$", "\\$" ); + dslPattern = dslPattern.replace( "$", + "\\$" ); //A DSL Pattern can contain Regex itself, for example "When the ages is less than {num:1?[0-9]?[0-9]}" - String regex = dslPattern.replaceAll( "\\{.*?\\}", "(.*)" ); + String regex = dslPattern.replaceAll( "\\{.*?\\}", + "(.*)" ); Matcher matcher = Pattern.compile( regex ).matcher( dslLine ); if ( matcher.matches() ) { - dslPattern = dslPattern.replace( "\\$", "$" ); + dslPattern = dslPattern.replace( "\\$", + "$" ); dslSentence.setDefinition( dslPattern ); for ( int i = 0; i < matcher.groupCount(); i++ ) { dslSentence.getValues().get( i ).setValue( matcher.group( i + 1 ) ); @@ -2696,9 +2778,9 @@ private DSLSentence toDSLSentence( List<String> dslPatterns, return dslSentence; } - private PortableParameterDefinition buildPortableParameterDefinition( String name, - String value, - Map<String, String> boundParams ) { + private PortableParameterDefinition buildPortableParameterDefinition( final String name, + final String value, + final Map<String, String> boundParams ) { PortableParameterDefinition paramDef; String type = boundParams.get( value ); if ( type != null ) { @@ -2720,7 +2802,8 @@ private PortableParameterDefinition buildPortableParameterDefinition( String nam ( (PortableBooleanParameterDefinition) paramDef ).setValue( b ); } else if ( value.startsWith( "\"" ) ) { paramDef = new PortableStringParameterDefinition(); - ( (PortableStringParameterDefinition) paramDef ).setValue( value.substring( 1, value.length() - 1 ) ); + ( (PortableStringParameterDefinition) paramDef ).setValue( value.substring( 1, + value.length() - 1 ) ); } else if ( Character.isDigit( value.charAt( 0 ) ) ) { if ( value.endsWith( "f" ) ) { paramDef = new PortableFloatParameterDefinition(); @@ -2732,17 +2815,18 @@ private PortableParameterDefinition buildPortableParameterDefinition( String nam } else { throw new RuntimeException( "Unknown parameter " + value ); } - paramDef.setName( name.substring( 1, name.length() - 1 ) ); + paramDef.setName( name.substring( 1, + name.length() - 1 ) ); return paramDef; } - private void addSettersToAction( Map<String, List<String>> setStatements, - String variable, - ActionFieldList action, - Map<String, String> boundParams, - PackageDataModelOracle dmo, - Imports imports, - boolean isJavaDialect ) { + private void addSettersToAction( final Map<String, List<String>> setStatements, + final String variable, + final ActionFieldList action, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo, + final Imports imports, + final boolean isJavaDialect ) { addSettersToAction( setStatements.remove( variable ), action, boundParams, @@ -2751,43 +2835,56 @@ private void addSettersToAction( Map<String, List<String>> setStatements, isJavaDialect ); } - private void addSettersToAction( List<String> setters, - ActionFieldList action, - Map<String, String> boundParams, - PackageDataModelOracle dmo, - Imports imports, - boolean isJavaDialect ) { + private void addSettersToAction( final List<String> setters, + final ActionFieldList action, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo, + final Imports imports, + final boolean isJavaDialect ) { if ( setters != null ) { for ( String statement : setters ) { int dotPos = statement.indexOf( '.' ); int argStart = statement.indexOf( '(' ); - String methodName = statement.substring( dotPos + 1, argStart ).trim(); - addSetterToAction( action, boundParams, dmo, imports, isJavaDialect, statement, methodName ); + String methodName = statement.substring( dotPos + 1, + argStart ).trim(); + addSetterToAction( action, + boundParams, + dmo, + imports, + isJavaDialect, + statement, + methodName ); } } } - private void addModifiersToAction( String variable, - String modifiers, - ActionFieldList action, - Map<String, String> boundParams, - PackageDataModelOracle dmo, - Imports imports, - boolean isJavaDialect ) { + private void addModifiersToAction( final String modifiers, + final ActionFieldList action, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo, + final Imports imports, + final boolean isJavaDialect ) { for ( String statement : splitArgumentsList( modifiers ) ) { int argStart = statement.indexOf( '(' ); - String methodName = statement.substring( 0, argStart ).trim(); - addSetterToAction( action, boundParams, dmo, imports, isJavaDialect, statement, methodName ); - } - } - - private void addSetterToAction( ActionFieldList action, - Map<String, String> boundParams, - PackageDataModelOracle dmo, - Imports imports, - boolean isJavaDialect, - String statement, - String methodName ) { + String methodName = statement.substring( 0, + argStart ).trim(); + addSetterToAction( action, + boundParams, + dmo, + imports, + isJavaDialect, + statement, + methodName ); + } + } + + private void addSetterToAction( final ActionFieldList action, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo, + final Imports imports, + final boolean isJavaDialect, + final String statement, + final String methodName ) { String field = getSettedField( methodName ); String value = unwrapParenthesis( statement ); String dataType = inferDataType( action, @@ -2804,27 +2901,41 @@ private void addSetterToAction( ActionFieldList action, field, value, dataType, - boundParams, - dmo ) ); + boundParams ) ); } - private ActionFieldValue buildFieldValue( boolean isJavaDialect, + private ActionFieldValue buildFieldValue( final boolean isJavaDialect, String field, - String value, - String dataType, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + final String value, + final String dataType, + final Map<String, String> boundParams ) { if ( value.contains( "wiWorkItem.getResult" ) ) { field = field.substring( 0, 1 ).toUpperCase() + field.substring( 1 ); String wiParam = field.substring( "Results".length() ); if ( wiParam.equals( "BooleanResult" ) ) { - return new ActionWorkItemFieldValue( field, DataType.TYPE_BOOLEAN, "WorkItem", wiParam, Boolean.class.getName() ); + return new ActionWorkItemFieldValue( field, + DataType.TYPE_BOOLEAN, + "WorkItem", + wiParam, + Boolean.class.getName() ); } else if ( wiParam.equals( "StringResult" ) ) { - return new ActionWorkItemFieldValue( field, DataType.TYPE_STRING, "WorkItem", wiParam, String.class.getName() ); + return new ActionWorkItemFieldValue( field, + DataType.TYPE_STRING, + "WorkItem", + wiParam, + String.class.getName() ); } else if ( wiParam.equals( "IntegerResult" ) ) { - return new ActionWorkItemFieldValue( field, DataType.TYPE_NUMERIC_INTEGER, "WorkItem", wiParam, Integer.class.getName() ); + return new ActionWorkItemFieldValue( field, + DataType.TYPE_NUMERIC_INTEGER, + "WorkItem", + wiParam, + Integer.class.getName() ); } else if ( wiParam.equals( "FloatResult" ) ) { - return new ActionWorkItemFieldValue( field, DataType.TYPE_NUMERIC_FLOAT, "WorkItem", wiParam, Float.class.getName() ); + return new ActionWorkItemFieldValue( field, + DataType.TYPE_NUMERIC_FLOAT, + "WorkItem", + wiParam, + Float.class.getName() ); } } ActionFieldValue fieldValue = new ActionFieldValue( field, @@ -2840,7 +2951,7 @@ private ActionFieldValue buildFieldValue( boolean isJavaDialect, return fieldValue; } - private boolean isJavaIdentifier( String name ) { + private boolean isJavaIdentifier( final String name ) { if ( name == null || name.length() == 0 || !Character.isJavaIdentifierStart( name.charAt( 0 ) ) ) { return false; } @@ -2852,11 +2963,12 @@ private boolean isJavaIdentifier( String name ) { return true; } - private String getSettedField( String methodName ) { + private String getSettedField( final String methodName ) { if ( methodName.length() > 3 && methodName.startsWith( "set" ) ) { String field = methodName.substring( 3 ); if ( Character.isUpperCase( field.charAt( 0 ) ) ) { - return field.substring( 0, 1 ).toLowerCase() + field.substring( 1 ); + return field.substring( 0, + 1 ).toLowerCase() + field.substring( 1 ); } else { return field; } @@ -2864,13 +2976,14 @@ private String getSettedField( String methodName ) { return null; } - private String getStatementType( String fact, - Map<String, String> factsType ) { + private String getStatementType( final String fact, + final Map<String, String> factsType ) { String type = null; if ( fact.startsWith( "new " ) ) { String inserted = fact.substring( 4 ).trim(); if ( inserted.endsWith( "()" ) ) { - type = inserted.substring( 0, inserted.length() - 2 ).trim(); + type = inserted.substring( 0, + inserted.length() - 2 ).trim(); } } else { type = factsType.get( fact ); @@ -2878,23 +2991,29 @@ private String getStatementType( String fact, return type; } - private Expr parseExpr( String expr, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + private Expr parseExpr( final String expr, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo ) { List<String> splittedExpr = splitExpression( expr ); if ( splittedExpr.size() == 1 ) { String singleExpr = splittedExpr.get( 0 ); if ( singleExpr.startsWith( "(" ) ) { - return parseExpr( singleExpr.substring( 1 ), boundParams, dmo ); + return parseExpr( singleExpr.substring( 1 ), + boundParams, + dmo ); } else if ( singleExpr.startsWith( "eval" ) ) { return new EvalExpr( unwrapParenthesis( singleExpr ) ); } else { - return new SimpleExpr( singleExpr, boundParams, dmo ); + return new SimpleExpr( singleExpr, + boundParams, + dmo ); } } ComplexExpr complexExpr = new ComplexExpr( splittedExpr.get( 1 ) ); for ( int i = 0; i < splittedExpr.size(); i += 2 ) { - complexExpr.subExprs.add( parseExpr( splittedExpr.get( i ), boundParams, dmo ) ); + complexExpr.subExprs.add( parseExpr( splittedExpr.get( i ), + boundParams, + dmo ) ); } return complexExpr; } @@ -2903,7 +3022,7 @@ private enum SplitterState { START, EXPR, PIPE, OR, AMPERSAND, AND, NESTED } - private List<String> splitExpression( String expr ) { + private List<String> splitExpression( final String expr ) { List<String> splittedExpr = new ArrayList<String>(); int nestingLevel = 0; SplitterState status = SplitterState.START; @@ -3003,8 +3122,8 @@ private List<String> splitExpression( String expr ) { private interface Expr { - FieldConstraint asFieldConstraint( RuleModel m, - FactPattern factPattern ); + FieldConstraint asFieldConstraint( final RuleModel m, + final FactPattern factPattern ); } private static class SimpleExpr implements Expr { @@ -3013,16 +3132,16 @@ private static class SimpleExpr implements Expr { private final Map<String, String> boundParams; private final PackageDataModelOracle dmo; - private SimpleExpr( String expr, - Map<String, String> boundParams, - PackageDataModelOracle dmo ) { + private SimpleExpr( final String expr, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo ) { this.expr = expr; this.boundParams = boundParams; this.dmo = dmo; } - public FieldConstraint asFieldConstraint( RuleModel m, - FactPattern factPattern ) { + public FieldConstraint asFieldConstraint( final RuleModel m, + final FactPattern factPattern ) { String fieldName = expr; String value = null; @@ -3042,17 +3161,18 @@ public FieldConstraint asFieldConstraint( RuleModel m, } } + boolean isExpression = fieldName.contains( "." ) || fieldName.endsWith( "()" ); return createFieldConstraint( m, factPattern, fieldName, value, operator, - fieldName.contains( "." ) ); + isExpression ); } - private SingleFieldConstraint createNullCheckFieldConstraint( RuleModel m, - FactPattern factPattern, - String fieldName ) { + private SingleFieldConstraint createNullCheckFieldConstraint( final RuleModel m, + final FactPattern factPattern, + final String fieldName ) { return createFieldConstraint( m, factPattern, fieldName, @@ -3061,16 +3181,17 @@ private SingleFieldConstraint createNullCheckFieldConstraint( RuleModel m, true ); } - private SingleFieldConstraint createFieldConstraint( RuleModel m, - FactPattern factPattern, - String fieldName, + private SingleFieldConstraint createFieldConstraint( final RuleModel m, + final FactPattern factPattern, + final String fieldName, String value, - String operator, - boolean isExpression ) { + final String operator, + final boolean isExpression ) { String operatorParams = null; if ( value != null && value.startsWith( "[" ) ) { int endSquare = value.indexOf( ']' ); - operatorParams = value.substring( 1, endSquare ).trim(); + operatorParams = value.substring( 1, + endSquare ).trim(); value = value.substring( endSquare + 1 ).trim(); } @@ -3089,11 +3210,13 @@ private SingleFieldConstraint createFieldConstraint( RuleModel m, if ( operatorParams != null ) { int i = 0; for ( String param : operatorParams.split( "," ) ) { - ( (BaseSingleFieldConstraint) fieldConstraint ).setParameter( "" + i++, param.trim() ); + fieldConstraint.setParameter( "" + i++, + param.trim() ); } - ( (BaseSingleFieldConstraint) fieldConstraint ).setParameter( "org.drools.workbench.models.commons.backend.rule.visibleParameterSet", "" + i ); - ( (BaseSingleFieldConstraint) fieldConstraint ).setParameter( "org.drools.workbench.models.commons.backend.rule.operatorParameterGenerator", - "org.drools.workbench.models.commons.backend.rule.CEPOperatorParameterDRLBuilder" ); + fieldConstraint.setParameter( "org.drools.workbench.models.commons.backend.rule.visibleParameterSet", + "" + i ); + fieldConstraint.setParameter( "org.drools.workbench.models.commons.backend.rule.operatorParameterGenerator", + "org.drools.workbench.models.commons.backend.rule.CEPOperatorParameterDRLBuilder" ); } if ( fieldName.equals( "this" ) && ( operator == null || operator.equals( "!= null" ) ) ) { @@ -3101,7 +3224,9 @@ private SingleFieldConstraint createFieldConstraint( RuleModel m, } fieldConstraint.setFactType( factPattern.getFactType() ); - ModelField field = findField( findFields( dmo, m, factPattern.getFactType() ), + ModelField field = findField( findFields( m, + dmo, + factPattern.getFactType() ), fieldConstraint.getFieldName() ); if ( field != null && ( fieldConstraint.getFieldType() == null || fieldConstraint.getFieldType().trim().length() == 0 ) ) { @@ -3110,11 +3235,11 @@ private SingleFieldConstraint createFieldConstraint( RuleModel m, return fieldConstraint; } - private SingleFieldConstraint createExpressionBuilderConstraint( RuleModel m, - FactPattern factPattern, - String fieldName, - String operator, - String value ) { + private SingleFieldConstraint createExpressionBuilderConstraint( final RuleModel m, + final FactPattern factPattern, + final String fieldName, + final String operator, + final String value ) { // TODO: we should find a way to know when the expression uses a getter and in this case create a plain SingleFieldConstraint //int dotPos = fieldName.lastIndexOf('.'); //SingleFieldConstraint con = createSingleFieldConstraint(dotPos > 0 ? fieldName.substring(dotPos+1) : fieldName, operator, value); @@ -3125,6 +3250,28 @@ private SingleFieldConstraint createExpressionBuilderConstraint( RuleModel m, operator, value ); + return con; + } + + private SingleFieldConstraint createSingleFieldConstraint( final RuleModel m, + final FactPattern factPattern, + String fieldName, + final String operator, + final String value ) { + SingleFieldConstraint con = new SingleFieldConstraint(); + fieldName = setFieldBindingOnContraint( factPattern.getFactType(), + fieldName, + m, + con, + boundParams ); + con.setFieldName( fieldName ); + setOperatorAndValueOnConstraint( m, + operator, + value, + factPattern, + con ); + + //Setup parent relationships for SingleFieldConstraints for ( FieldConstraint fieldConstraint : factPattern.getFieldConstraints() ) { if ( fieldConstraint instanceof SingleFieldConstraint ) { SingleFieldConstraint sfc = (SingleFieldConstraint) fieldConstraint; @@ -3138,33 +3285,18 @@ private SingleFieldConstraint createExpressionBuilderConstraint( RuleModel m, } } - if ( con.getParent() == null && !( con instanceof SingleFieldConstraintEBLeftSide ) ) { + if ( con.getParent() == null ) { con.setParent( createParentFor( m, factPattern, fieldName ) ); } return con; } - private SingleFieldConstraint createSingleFieldConstraint( RuleModel m, - FactPattern factPattern, - String fieldName, - String operator, - String value ) { - SingleFieldConstraint con = new SingleFieldConstraint(); - fieldName = setFieldBindingOnContraint( factPattern.getFactType(), - fieldName, - m, con, - boundParams ); - con.setFieldName( fieldName ); - setOperatorAndValueOnConstraint( m, operator, value, factPattern, con ); - return con; - } - - private SingleFieldConstraintEBLeftSide createSingleFieldConstraintEBLeftSide( RuleModel m, - FactPattern factPattern, + private SingleFieldConstraintEBLeftSide createSingleFieldConstraintEBLeftSide( final RuleModel m, + final FactPattern factPattern, String fieldName, - String operator, - String value ) { + final String operator, + final String value ) { SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide(); fieldName = setFieldBindingOnContraint( factPattern.getFactType(), @@ -3172,10 +3304,14 @@ private SingleFieldConstraintEBLeftSide createSingleFieldConstraintEBLeftSide( R m, con, boundParams ); - String classType = getFQFactType( m, factPattern.getFactType() ); + String classType = getFQFactType( m, + factPattern.getFactType() ); con.getExpressionLeftSide().appendPart( new ExpressionUnboundFact( factPattern ) ); - parseExpression( m, classType, fieldName, con.getExpressionLeftSide() ); + parseExpression( m, + classType, + fieldName, + con.getExpressionLeftSide() ); setOperatorAndValueOnConstraint( m, operator, @@ -3186,10 +3322,10 @@ private SingleFieldConstraintEBLeftSide createSingleFieldConstraintEBLeftSide( R return con; } - private ExpressionFormLine parseExpression( RuleModel m, + private ExpressionFormLine parseExpression( final RuleModel m, String factType, - String fieldName, - ExpressionFormLine expression ) { + final String fieldName, + final ExpressionFormLine expression ) { String[] splits = fieldName.split( "\\." ); boolean isBoundParam = false; @@ -3199,9 +3335,13 @@ private ExpressionFormLine parseExpression( RuleModel m, isBoundParam = true; } - ModelField[] typeFields = findFields( dmo, - m, + //An ExpressionPart can be a Field or a Method + ModelField[] typeFields = findFields( m, + dmo, factType ); + List<MethodInfo> methodInfos = getMethodInfosForType( m, + dmo, + factType ); //Handle all but last expression part for ( int i = 0; i < splits.length - 1; i++ ) { @@ -3210,6 +3350,7 @@ private ExpressionFormLine parseExpression( RuleModel m, expression.appendPart( new ExpressionField( expressionPart, factType, DataType.TYPE_THIS ) ); + } else if ( isBoundParam ) { ModelField currentFact = findFact( dmo.getProjectModelFields(), factType ); @@ -3217,18 +3358,35 @@ private ExpressionFormLine parseExpression( RuleModel m, currentFact.getClassName(), currentFact.getType() ) ); isBoundParam = false; + } else { + //An ExpressionPart can be a Field or a Method + String currentClassName = null; ModelField currentField = findField( typeFields, expressionPart ); + if ( currentField != null ) { + currentClassName = currentField.getClassName(); + } + MethodInfo currentMethodInfo = findMethodInfo( methodInfos, + expressionPart ); + if ( currentMethodInfo != null ) { + currentClassName = currentMethodInfo.getReturnClassType(); + } - processExpressionPart( factType, + processExpressionPart( m, + factType, currentField, + currentMethodInfo, expression, expressionPart ); - typeFields = findFields( dmo, - m, - currentField.getClassName() ); + //Refresh field and method information based + typeFields = findFields( m, + dmo, + currentClassName ); + methodInfos = getMethodInfosForType( m, + dmo, + currentClassName ); } } @@ -3236,9 +3394,13 @@ private ExpressionFormLine parseExpression( RuleModel m, String expressionPart = normalizeExpressionPart( splits[ splits.length - 1 ] ); ModelField currentField = findField( typeFields, expressionPart ); + MethodInfo currentMethodInfo = findMethodInfo( methodInfos, + expressionPart ); - processExpressionPart( factType, + processExpressionPart( m, + factType, currentField, + currentMethodInfo, expression, expressionPart ); @@ -3248,41 +3410,34 @@ private ExpressionFormLine parseExpression( RuleModel m, private String normalizeExpressionPart( String expressionPart ) { int parenthesisPos = expressionPart.indexOf( '(' ); if ( parenthesisPos > 0 ) { - expressionPart = expressionPart.substring( 0, parenthesisPos ); + expressionPart = expressionPart.substring( 0, + parenthesisPos ); } return expressionPart.trim(); } - private void processExpressionPart( final String factType, + private void processExpressionPart( final RuleModel m, + final String factType, final ModelField currentField, + final MethodInfo currentMethodInfo, final ExpressionFormLine expression, final String expressionPart ) { if ( currentField == null ) { - final String previousClassName = expression.getClassType(); - final List<MethodInfo> mis = dmo.getProjectMethodInformation().get( previousClassName ); - boolean isMethod = false; - if ( mis != null ) { - for ( MethodInfo mi : mis ) { - if ( mi.getName().equals( expressionPart ) ) { - expression.appendPart( new ExpressionMethod( mi.getName(), - mi.getReturnClassType(), - mi.getGenericType(), - mi.getParametricReturnType() ) ); - isMethod = true; - break; - } - } - } - if ( isMethod == false ) { + boolean isMethod = currentMethodInfo != null; + if ( isMethod ) { + expression.appendPart( new ExpressionMethod( currentMethodInfo.getName(), + currentMethodInfo.getReturnClassType(), + currentMethodInfo.getGenericType(), + currentMethodInfo.getParametricReturnType() ) ); + } else { expression.appendPart( new ExpressionText( expressionPart ) ); } } else if ( "Collection".equals( currentField.getType() ) ) { - expression.appendPart( - new ExpressionCollection( expressionPart, - currentField.getClassName(), - currentField.getType(), - dmo.getProjectFieldParametersType().get( factType + "#" + expressionPart ) ) + expression.appendPart( new ExpressionCollection( expressionPart, + currentField.getClassName(), + currentField.getType(), + dmo.getProjectFieldParametersType().get( factType + "#" + expressionPart ) ) ); } else { expression.appendPart( new ExpressionField( expressionPart, @@ -3292,8 +3447,8 @@ private void processExpressionPart( final String factType, } - private String getFQFactType( RuleModel ruleModel, - String factType ) { + private String getFQFactType( final RuleModel ruleModel, + final String factType ) { Set<String> factTypes = dmo.getProjectModelFields().keySet(); @@ -3316,8 +3471,8 @@ private String getFQFactType( RuleModel ruleModel, return factType; } - private ModelField findFact( Map<String, ModelField[]> modelFields, - String factType ) { + private ModelField findFact( final Map<String, ModelField[]> modelFields, + final String factType ) { final ModelField[] typeFields = modelFields.get( factType ); if ( typeFields == null ) { return null; @@ -3330,35 +3485,41 @@ private ModelField findFact( Map<String, ModelField[]> modelFields, return null; } - private SingleFieldConstraint createParentFor( RuleModel m, - FactPattern factPattern, - String fieldName ) { + private SingleFieldConstraint createParentFor( final RuleModel m, + final FactPattern factPattern, + final String fieldName ) { int dotPos = fieldName.lastIndexOf( '.' ); if ( dotPos > 0 ) { - SingleFieldConstraint constraint = createNullCheckFieldConstraint( m, factPattern, fieldName.substring( 0, dotPos ) ); + SingleFieldConstraint constraint = createNullCheckFieldConstraint( m, + factPattern, + fieldName.substring( 0, + dotPos ) ); factPattern.addConstraint( constraint ); return constraint; } return null; } - private String setFieldBindingOnContraint( - String factType, - String fieldName, - RuleModel model, - SingleFieldConstraint con, - Map<String, String> boundParams ) { + private String setFieldBindingOnContraint( final String factType, + String fieldName, + final RuleModel model, + final SingleFieldConstraint con, + final Map<String, String> boundParams ) { int colonPos = fieldName.indexOf( ':' ); if ( colonPos > 0 ) { - String fieldBinding = fieldName.substring( 0, colonPos ).trim(); + String fieldBinding = fieldName.substring( 0, + colonPos ).trim(); con.setFieldBinding( fieldBinding ); fieldName = fieldName.substring( colonPos + 1 ).trim(); - ModelField[] fields = findFields( dmo, model, factType ); + ModelField[] fields = findFields( model, + dmo, + factType ); if ( fields != null ) { for ( ModelField field : fields ) { if ( field.getName().equals( fieldName ) ) { - boundParams.put( fieldBinding, field.getType() ); + boundParams.put( fieldBinding, + field.getType() ); } } } @@ -3367,11 +3528,11 @@ private String setFieldBindingOnContraint( return fieldName; } - private String setOperatorAndValueOnConstraint( RuleModel m, - String operator, - String value, - FactPattern factPattern, - SingleFieldConstraint con ) { + private String setOperatorAndValueOnConstraint( final RuleModel m, + final String operator, + final String value, + final FactPattern factPattern, + final SingleFieldConstraint con ) { con.setOperator( operator ); String type = null; boolean isAnd = false; @@ -3379,7 +3540,11 @@ private String setOperatorAndValueOnConstraint( RuleModel m, if ( value != null ) { isAnd = value.contains( "&&" ); splittedValue = isAnd ? value.split( "\\&\\&" ) : value.split( "\\|\\|" ); - type = setValueOnConstraint( m, operator, factPattern, con, splittedValue[ 0 ].trim() ); + type = setValueOnConstraint( m, + operator, + factPattern, + con, + splittedValue[ 0 ].trim() ); } if ( splittedValue.length > 1 ) { @@ -3391,23 +3556,28 @@ private String setOperatorAndValueOnConstraint( RuleModel m, connectiveConstraints[ i ] = new ConnectiveConstraint(); connectiveConstraints[ i ].setOperator( ( isAnd ? "&& " : "|| " ) + connectiveOperator ); - setValueOnConstraint( m, operator, factPattern, connectiveConstraints[ i ], connectiveValue ); + setValueOnConstraint( m, + operator, + factPattern, + connectiveConstraints[ i ], + connectiveValue ); } con.setConnectives( connectiveConstraints ); } return type; } - private String setValueOnConstraint( RuleModel m, - String operator, - FactPattern factPattern, - BaseSingleFieldConstraint con, + private String setValueOnConstraint( final RuleModel m, + final String operator, + final FactPattern factPattern, + final BaseSingleFieldConstraint con, String value ) { String type = null; if ( value.startsWith( "\"" ) ) { type = DataType.TYPE_STRING; con.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL ); - con.setValue( value.substring( 1, value.length() - 1 ) ); + con.setValue( value.substring( 1, + value.length() - 1 ) ); } else if ( value.startsWith( "(" ) ) { if ( operator != null && operator.contains( "in" ) ) { value = unwrapParenthesis( value ); @@ -3428,8 +3598,12 @@ private String setValueOnConstraint( RuleModel m, con ) ) { type = DataType.TYPE_COMPARABLE; con.setConstraintValueType( SingleFieldConstraint.TYPE_ENUM ); - } else if ( value.indexOf( '.' ) > 0 && boundParams.containsKey( value.substring( 0, value.indexOf( '.' ) ).trim() ) ) { - con.setExpressionValue( parseExpression( m, null, value, new ExpressionFormLine() ) ); + } else if ( value.indexOf( '.' ) > 0 && boundParams.containsKey( value.substring( 0, + value.indexOf( '.' ) ).trim() ) ) { + con.setExpressionValue( parseExpression( m, + null, + value, + new ExpressionFormLine() ) ); con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_EXPR_BUILDER_VALUE ); value = ""; } else { @@ -3438,10 +3612,12 @@ private String setValueOnConstraint( RuleModel m, } else { if ( value.endsWith( "I" ) ) { type = DataType.TYPE_NUMERIC_BIGINTEGER; - value = value.substring( 0, value.length() - 1 ); + value = value.substring( 0, + value.length() - 1 ); } else if ( value.endsWith( "B" ) ) { type = DataType.TYPE_NUMERIC_BIGDECIMAL; - value = value.substring( 0, value.length() - 1 ); + value = value.substring( 0, + value.length() - 1 ); } else if ( value.endsWith( "f" ) ) { type = DataType.TYPE_NUMERIC_FLOAT; } else if ( value.endsWith( "d" ) ) { @@ -3461,9 +3637,9 @@ private String setValueOnConstraint( RuleModel m, return type; } - private boolean isEnumerationValue( RuleModel ruleModel, - FactPattern factPattern, - BaseSingleFieldConstraint con ) { + private boolean isEnumerationValue( final RuleModel ruleModel, + final FactPattern factPattern, + final BaseSingleFieldConstraint con ) { String factType = null; String fieldName = null; if ( con instanceof SingleFieldConstraintEBLeftSide ) { @@ -3483,7 +3659,8 @@ private boolean isEnumerationValue( RuleModel ruleModel, return false; } - final String fullyQualifiedFactType = getFQFactType( ruleModel, factType ); + final String fullyQualifiedFactType = getFQFactType( ruleModel, + factType ); final String key = fullyQualifiedFactType + "#" + fieldName; final Map<String, String[]> projectJavaEnumDefinitions = dmo.getProjectJavaEnumDefinitions(); @@ -3496,16 +3673,17 @@ private static class ComplexExpr implements Expr { private final List<Expr> subExprs = new ArrayList<Expr>(); private final String connector; - private ComplexExpr( String connector ) { + private ComplexExpr( final String connector ) { this.connector = connector; } - public FieldConstraint asFieldConstraint( RuleModel m, - FactPattern factPattern ) { + public FieldConstraint asFieldConstraint( final RuleModel m, + final FactPattern factPattern ) { CompositeFieldConstraint comp = new CompositeFieldConstraint(); comp.setCompositeJunctionType( connector.equals( "&&" ) ? CompositeFieldConstraint.COMPOSITE_TYPE_AND : CompositeFieldConstraint.COMPOSITE_TYPE_OR ); for ( Expr expr : subExprs ) { - comp.addConstraint( expr.asFieldConstraint( m, factPattern ) ); + comp.addConstraint( expr.asFieldConstraint( m, + factPattern ) ); } return comp; } @@ -3515,12 +3693,12 @@ private static class EvalExpr implements Expr { private final String expr; - private EvalExpr( String expr ) { + private EvalExpr( final String expr ) { this.expr = expr; } - public FieldConstraint asFieldConstraint( RuleModel m, - FactPattern factPattern ) { + public FieldConstraint asFieldConstraint( final RuleModel m, + final FactPattern factPattern ) { SingleFieldConstraint con = new SingleFieldConstraint(); con.setConstraintValueType( SingleFieldConstraint.TYPE_PREDICATE ); con.setValue( expr ); diff --git a/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelPersistenceHelper.java b/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelPersistenceHelper.java index 768e3350b2f..53e039cca27 100644 --- a/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelPersistenceHelper.java +++ b/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelPersistenceHelper.java @@ -25,14 +25,15 @@ class RuleModelPersistenceHelper { - static String unwrapParenthesis( String s ) { + static String unwrapParenthesis( final String s ) { int start = s.indexOf( '(' ); int end = s.lastIndexOf( ')' ); - return s.substring( start + 1, end ).trim(); + return s.substring( start + 1, + end ).trim(); } - static String getSimpleFactType( String className, - PackageDataModelOracle dmo ) { + static String getSimpleFactType( final String className, + final PackageDataModelOracle dmo ) { for ( String type : dmo.getProjectModelFields().keySet() ) { if ( type.equals( className ) ) { return type.substring( type.lastIndexOf( "." ) + 1 ); @@ -169,10 +170,9 @@ static int inferFieldNature( final String dataType, return nature; } - static ModelField[] findFields( - PackageDataModelOracle dmo, - RuleModel m, - String type ) { + static ModelField[] findFields( final RuleModel m, + final PackageDataModelOracle dmo, + final String type ) { ModelField[] fields = dmo.getProjectModelFields().get( type ); if ( fields != null ) { return fields; @@ -189,9 +189,8 @@ static ModelField[] findFields( return dmo.getProjectModelFields().get( m.getPackageName() + "." + type ); } - static ModelField findField( - ModelField[] typeFields, - String fieldName ) { + static ModelField findField( final ModelField[] typeFields, + final String fieldName ) { if ( typeFields != null && fieldName != null ) { for ( ModelField typeField : typeFields ) { if ( typeField.getName().equals( fieldName ) ) { @@ -202,11 +201,24 @@ static ModelField findField( return null; } - static String inferDataType( ActionFieldList action, - String field, - Map<String, String> boundParams, - PackageDataModelOracle dmo, - Imports imports ) { + static MethodInfo findMethodInfo( final List<MethodInfo> methodInfos, + final String fieldName ) { + if ( methodInfos != null && fieldName != null ) { + for ( MethodInfo methodInfo : methodInfos ) { + if ( methodInfo.getName().equals( fieldName ) ) { + return methodInfo; + } + } + } + return null; + + } + + static String inferDataType( final ActionFieldList action, + final String field, + final Map<String, String> boundParams, + final PackageDataModelOracle dmo, + final Imports imports ) { String factType = null; if ( action instanceof ActionInsertFact ) { factType = ( (ActionInsertFact) action ).getFactType(); @@ -250,9 +262,9 @@ static String inferDataType( ActionFieldList action, return null; } - static String inferDataType( String param, - Map<String, String> boundParams, - boolean isJavaDialect ) { + static String inferDataType( final String param, + final Map<String, String> boundParams, + final boolean isJavaDialect ) { if ( param.startsWith( "sdf.parse(\"" ) ) { return DataType.TYPE_DATE; } else if ( param.startsWith( "\"" ) ) { @@ -271,10 +283,10 @@ static String inferDataType( String param, return DataType.TYPE_NUMERIC; } - static String adjustParam( String dataType, - String param, - Map<String, String> boundParams, - boolean isJavaDialect ) { + static String adjustParam( final String dataType, + final String param, + final Map<String, String> boundParams, + final boolean isJavaDialect ) { if ( dataType == DataType.TYPE_DATE ) { return param.substring( "sdf.parse(\"".length(), param.length() - 2 ); @@ -302,9 +314,9 @@ static String adjustParam( String dataType, return param; } - static List<MethodInfo> getMethodInfosForType( RuleModel model, - PackageDataModelOracle dmo, - String variableType ) { + static List<MethodInfo> getMethodInfosForType( final RuleModel model, + final PackageDataModelOracle dmo, + final String variableType ) { List<MethodInfo> methods = dmo.getProjectMethodInformation().get( variableType ); if ( methods == null ) { for ( String imp : model.getImports().getImportStrings() ) { @@ -318,4 +330,5 @@ static List<MethodInfo> getMethodInfosForType( RuleModel model, } return methods; } + } diff --git a/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceTest.java b/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceTest.java index 7158f86a99f..b109679b122 100644 --- a/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceTest.java +++ b/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceTest.java @@ -16,6 +16,7 @@ package org.drools.workbench.models.commons.backend.rule; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -25,6 +26,7 @@ import org.drools.workbench.models.datamodel.imports.Import; import org.drools.workbench.models.datamodel.oracle.DataType; import org.drools.workbench.models.datamodel.oracle.FieldAccessorsAndMutators; +import org.drools.workbench.models.datamodel.oracle.MethodInfo; import org.drools.workbench.models.datamodel.oracle.ModelField; import org.drools.workbench.models.datamodel.oracle.PackageDataModelOracle; import org.drools.workbench.models.datamodel.rule.ActionCallMethod; @@ -4408,6 +4410,18 @@ public void testLHSFormula() { con2.setValue( "0" ); p.addConstraint( con2 ); + final HashMap<String, List<MethodInfo>> map = new HashMap<String, List<MethodInfo>>(); + final ArrayList<MethodInfo> methodInfos = new ArrayList<MethodInfo>(); + methodInfos.add( new MethodInfo( "intValue", + Collections.EMPTY_LIST, + "int", + null, + DataType.TYPE_NUMERIC_INTEGER ) ); + map.put( "Number", + methodInfos ); + + when( dmo.getProjectMethodInformation() ).thenReturn( map ); + String expected = "rule \"test\"\n" + "dialect \"mvel\"\n" + "when\n" @@ -4416,7 +4430,8 @@ public void testLHSFormula() { + "end"; checkMarshallUnmarshall( expected, - m ); + m, + dmo ); } @Test @@ -4445,6 +4460,18 @@ public void testLHSReturnType() { con2.setValue( "0" ); p.addConstraint( con2 ); + final HashMap<String, List<MethodInfo>> map = new HashMap<String, List<MethodInfo>>(); + final ArrayList<MethodInfo> methodInfos = new ArrayList<MethodInfo>(); + methodInfos.add( new MethodInfo( "intValue", + Collections.EMPTY_LIST, + "int", + null, + DataType.TYPE_NUMERIC_INTEGER ) ); + map.put( "Number", + methodInfos ); + + when( dmo.getProjectMethodInformation() ).thenReturn( map ); + String expected = "rule \"test\"\n" + "dialect \"mvel\"\n" + "when\n" @@ -4453,7 +4480,8 @@ public void testLHSReturnType() { + "end"; checkMarshallUnmarshall( expected, - m ); + m, + dmo ); } @Test diff --git a/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceUnmarshallingTest.java b/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceUnmarshallingTest.java index 1bbdce1bc31..d0bafc94790 100644 --- a/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceUnmarshallingTest.java +++ b/drools-workbench-models/drools-workbench-models-commons/src/test/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceUnmarshallingTest.java @@ -1751,8 +1751,8 @@ public void testNestedFieldConstraints() { sfp0.getConstraintValueType() ); assertNull( sfp0.getParent() ); - assertTrue( fp.getConstraint( 1 ) instanceof SingleFieldConstraint ); - SingleFieldConstraint sfp1 = (SingleFieldConstraint) fp.getConstraint( 1 ); + assertTrue( fp.getConstraint( 1 ) instanceof SingleFieldConstraintEBLeftSide ); + SingleFieldConstraintEBLeftSide sfp1 = (SingleFieldConstraintEBLeftSide) fp.getConstraint( 1 ); assertEquals( "ParentType", sfp1.getFactType() ); assertEquals( "parentChildField", @@ -1764,11 +1764,10 @@ public void testNestedFieldConstraints() { assertNull( sfp1.getValue() ); assertEquals( BaseSingleFieldConstraint.TYPE_UNDEFINED, sfp1.getConstraintValueType() ); - assertSame( sfp0, - sfp1.getParent() ); + assertNull( sfp1.getParent() ); - assertTrue( fp.getConstraint( 2 ) instanceof SingleFieldConstraint ); - SingleFieldConstraint sfp2 = (SingleFieldConstraint) fp.getConstraint( 2 ); + assertTrue( fp.getConstraint( 2 ) instanceof SingleFieldConstraintEBLeftSide ); + SingleFieldConstraintEBLeftSide sfp2 = (SingleFieldConstraintEBLeftSide) fp.getConstraint( 2 ); assertEquals( "childField", sfp2.getFieldName() ); assertEquals( "java.lang.String", @@ -1779,8 +1778,7 @@ public void testNestedFieldConstraints() { sfp2.getValue() ); assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL, sfp2.getConstraintValueType() ); - assertSame( sfp1, - sfp2.getParent() ); + assertNull( sfp2.getParent() ); } @Test @@ -4980,6 +4978,208 @@ public void testMethodCallWithTwoParametersIntegerAndString() throws Exception { actionCallMethod.getFieldValue( 1 ).getType() ); } + @Test + public void testLHSNumberExpressionWithoutThisPrefix() throws Exception { + String drl = "package org.mortgages;\n" + + "import java.lang.Number\n" + + "rule \"test\"\n" + + " dialect \"mvel\"\n" + + " when\n" + + " Number( intValue() > 5 )\n" + + " then\n" + + "end"; + + final HashMap<String, List<MethodInfo>> map = new HashMap<String, List<MethodInfo>>(); + final ArrayList<MethodInfo> methodInfos = new ArrayList<MethodInfo>(); + methodInfos.add( new MethodInfo( "intValue", + Collections.EMPTY_LIST, + "int", + null, + DataType.TYPE_NUMERIC_INTEGER ) ); + map.put( "java.lang.Number", + methodInfos ); + + when( dmo.getProjectMethodInformation() ).thenReturn( map ); + + final RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal( drl, + new ArrayList<String>(), + dmo ); + + assertNotNull( m ); + + assertEquals( 1, + m.lhs.length ); + + assertTrue( m.lhs[ 0 ] instanceof FactPattern ); + final FactPattern fp = (FactPattern) m.lhs[ 0 ]; + assertEquals( "Number", + fp.getFactType() ); + + assertEquals( 1, + fp.getNumberOfConstraints() ); + assertTrue( fp.getConstraint( 0 ) instanceof SingleFieldConstraintEBLeftSide ); + final SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fp.getConstraint( 0 ); + assertEquals( "int", + exp.getFieldType() ); + assertEquals( ">", + exp.getOperator() ); + assertEquals( "5", + exp.getValue() ); + + assertEquals( 2, + exp.getExpressionLeftSide().getParts().size() ); + assertTrue( exp.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionUnboundFact ); + final ExpressionUnboundFact expPart0 = (ExpressionUnboundFact) exp.getExpressionLeftSide().getParts().get( 0 ); + assertEquals( "Number", + expPart0.getFact().getFactType() ); + + assertTrue( exp.getExpressionLeftSide().getParts().get( 1 ) instanceof ExpressionMethod ); + final ExpressionMethod expPart1 = (ExpressionMethod) exp.getExpressionLeftSide().getParts().get( 1 ); + assertEquals( "intValue", + expPart1.getName() ); + } + + @Test + public void testLHSNumberExpressionWithThisPrefix() throws Exception { + String drl = "package org.mortgages;\n" + + "import java.lang.Number\n" + + "rule \"test\"\n" + + " dialect \"mvel\"\n" + + " when\n" + + " Number( this.intValue() > 5 )\n" + + " then\n" + + "end"; + + final HashMap<String, List<MethodInfo>> map = new HashMap<String, List<MethodInfo>>(); + final ArrayList<MethodInfo> methodInfos = new ArrayList<MethodInfo>(); + methodInfos.add( new MethodInfo( "intValue", + Collections.EMPTY_LIST, + "int", + null, + DataType.TYPE_NUMERIC_INTEGER ) ); + map.put( "java.lang.Number", + methodInfos ); + + when( dmo.getProjectMethodInformation() ).thenReturn( map ); + + final RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal( drl, + new ArrayList<String>(), + dmo ); + + assertNotNull( m ); + + assertEquals( 1, + m.lhs.length ); + + assertTrue( m.lhs[ 0 ] instanceof FactPattern ); + final FactPattern fp = (FactPattern) m.lhs[ 0 ]; + assertEquals( "Number", + fp.getFactType() ); + + assertEquals( 1, + fp.getNumberOfConstraints() ); + assertTrue( fp.getConstraint( 0 ) instanceof SingleFieldConstraintEBLeftSide ); + final SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fp.getConstraint( 0 ); + assertEquals( "int", + exp.getFieldType() ); + assertEquals( ">", + exp.getOperator() ); + assertEquals( "5", + exp.getValue() ); + + assertEquals( 3, + exp.getExpressionLeftSide().getParts().size() ); + assertTrue( exp.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionUnboundFact ); + final ExpressionUnboundFact expPart0 = (ExpressionUnboundFact) exp.getExpressionLeftSide().getParts().get( 0 ); + assertEquals( "Number", + expPart0.getFact().getFactType() ); + + assertTrue( exp.getExpressionLeftSide().getParts().get( 1 ) instanceof ExpressionField ); + final ExpressionField expPart1 = (ExpressionField) exp.getExpressionLeftSide().getParts().get( 1 ); + assertEquals( "this", + expPart1.getName() ); + + assertTrue( exp.getExpressionLeftSide().getParts().get( 2 ) instanceof ExpressionMethod ); + final ExpressionMethod expPart2 = (ExpressionMethod) exp.getExpressionLeftSide().getParts().get( 2 ); + assertEquals( "intValue", + expPart2.getName() ); + } + + @Test + public void testLHSNestedMethodCalls() throws Exception { + String drl = "package org.mortgages;\n" + + "rule \"test\"\n" + + " dialect \"mvel\"\n" + + " when\n" + + " Parent( methodToGetChild1().methodToGetChild2().field1 > 5 )\n" + + " then\n" + + "end"; + + addMethodInformation( "Parent", + "methodToGetChild1", + Collections.EMPTY_LIST, + "Child1", + null, + "Child1" ); + addMethodInformation( "Child1", + "methodToGetChild2", + Collections.EMPTY_LIST, + "Child2", + null, + "Child2" ); + addModelField( "Child2", + "field1", + "int", + DataType.TYPE_NUMERIC_INTEGER ); + + final RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal( drl, + new ArrayList<String>(), + dmo ); + + assertNotNull( m ); + + assertEquals( 1, + m.lhs.length ); + + assertTrue( m.lhs[ 0 ] instanceof FactPattern ); + final FactPattern fp = (FactPattern) m.lhs[ 0 ]; + assertEquals( "Parent", + fp.getFactType() ); + + assertEquals( 1, + fp.getNumberOfConstraints() ); + assertTrue( fp.getConstraint( 0 ) instanceof SingleFieldConstraintEBLeftSide ); + final SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fp.getConstraint( 0 ); + assertEquals( "int", + exp.getFieldType() ); + assertEquals( ">", + exp.getOperator() ); + assertEquals( "5", + exp.getValue() ); + + assertEquals( 4, + exp.getExpressionLeftSide().getParts().size() ); + assertTrue( exp.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionUnboundFact ); + final ExpressionUnboundFact expPart0 = (ExpressionUnboundFact) exp.getExpressionLeftSide().getParts().get( 0 ); + assertEquals( "Parent", + expPart0.getFact().getFactType() ); + + assertTrue( exp.getExpressionLeftSide().getParts().get( 1 ) instanceof ExpressionMethod ); + final ExpressionMethod expPart1 = (ExpressionMethod) exp.getExpressionLeftSide().getParts().get( 1 ); + assertEquals( "methodToGetChild1", + expPart1.getName() ); + + assertTrue( exp.getExpressionLeftSide().getParts().get( 2 ) instanceof ExpressionMethod ); + final ExpressionMethod expPart2 = (ExpressionMethod) exp.getExpressionLeftSide().getParts().get( 2 ); + assertEquals( "methodToGetChild2", + expPart2.getName() ); + + assertTrue( exp.getExpressionLeftSide().getParts().get( 3 ) instanceof ExpressionField ); + final ExpressionField expPart3 = (ExpressionField) exp.getExpressionLeftSide().getParts().get( 3 ); + assertEquals( "field1", + expPart3.getName() ); + } + private void assertEqualsIgnoreWhitespace( final String expected, final String actual ) { final String cleanExpected = expected.replaceAll( "\\s+",
ea3cbbfc7cebb2adc6edd8c9aaefd786c7cd05df
ReactiveX-RxJava
ObserveOn and SubscribeOn concurrency unit tests--- these are very rudimentary and may have a determinism problem due to the Thread.sleep-
p
https://github.com/ReactiveX/RxJava
diff --git a/rxjava-core/src/test/java/rx/concurrency/TestSchedulers.java b/rxjava-core/src/test/java/rx/concurrency/TestSchedulers.java index 59edfade39..119b2ce96e 100644 --- a/rxjava-core/src/test/java/rx/concurrency/TestSchedulers.java +++ b/rxjava-core/src/test/java/rx/concurrency/TestSchedulers.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; import org.junit.Test; @@ -395,4 +396,137 @@ public Subscription call(Scheduler scheduler, String state) { } } + @Test + public void testConcurrentOnNextFailsValidation() throws InterruptedException { + + final int count = 10; + final CountDownLatch latch = new CountDownLatch(count); + Observable<String> o = Observable.create(new Func1<Observer<String>, Subscription>() { + + @Override + public Subscription call(final Observer<String> observer) { + for (int i = 0; i < count; i++) { + final int v = i; + new Thread(new Runnable() { + + @Override + public void run() { + observer.onNext("v: " + v); + + latch.countDown(); + } + }).start(); + } + return Subscriptions.empty(); + } + }); + + ConcurrentObserverValidator<String> observer = new ConcurrentObserverValidator<String>(); + // this should call onNext concurrently + o.subscribe(observer); + + if (!observer.completed.await(3000, TimeUnit.MILLISECONDS)) { + fail("timed out"); + } + + if (observer.error.get() == null) { + fail("We expected error messages due to concurrency"); + } + } + + @Test + public void testObserveOn() throws InterruptedException { + + Observable<String> o = Observable.from("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"); + + ConcurrentObserverValidator<String> observer = new ConcurrentObserverValidator<String>(); + + o.observeOn(Schedulers.threadPoolForComputation()).subscribe(observer); + + if (!observer.completed.await(3000, TimeUnit.MILLISECONDS)) { + fail("timed out"); + } + + if (observer.error.get() != null) { + observer.error.get().printStackTrace(); + fail("Error: " + observer.error.get().getMessage()); + } + } + + @Test + public void testSubscribeOnNestedConcurrency() throws InterruptedException { + + Observable<String> o = Observable.from("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten") + .mapMany(new Func1<String, Observable<String>>() { + + @Override + public Observable<String> call(final String v) { + return Observable.create(new Func1<Observer<String>, Subscription>() { + + @Override + public Subscription call(final Observer<String> observer) { + observer.onNext("value_after_map-" + v); + observer.onCompleted(); + return Subscriptions.empty(); + } + }).subscribeOn(Schedulers.newThread()); // subscribe on a new thread + } + }); + + ConcurrentObserverValidator<String> observer = new ConcurrentObserverValidator<String>(); + + o.subscribe(observer); + + if (!observer.completed.await(3000, TimeUnit.MILLISECONDS)) { + fail("timed out"); + } + + if (observer.error.get() != null) { + observer.error.get().printStackTrace(); + fail("Error: " + observer.error.get().getMessage()); + } + } + + /** + * Used to determine if onNext is being invoked concurrently. + * + * @param <T> + */ + private static class ConcurrentObserverValidator<T> implements Observer<T> { + + final AtomicInteger concurrentCounter = new AtomicInteger(); + final AtomicReference<Exception> error = new AtomicReference<Exception>(); + final CountDownLatch completed = new CountDownLatch(1); + + @Override + public void onCompleted() { + completed.countDown(); + } + + @Override + public void onError(Exception e) { + completed.countDown(); + error.set(e); + } + + @Override + public void onNext(T args) { + int count = concurrentCounter.incrementAndGet(); + System.out.println("ConcurrentObserverValidator.onNext: " + args); + if (count > 1) { + onError(new RuntimeException("we should not have concurrent execution of onNext")); + } + try { + try { + // take some time so other onNext calls could pile up (I haven't yet thought of a way to do this without sleeping) + Thread.sleep(50); + } catch (InterruptedException e) { + // ignore + } + } finally { + concurrentCounter.decrementAndGet(); + } + } + + } }
ceddce542a8dea4d4a647e8c15598fe37393ebb3
hbase
HBASE-3591 completebulkload doesn't honor generic- -D options--git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1076709 13f79535-47bb-0310-9956-ffa450edef68-
c
https://github.com/apache/hbase
diff --git a/CHANGES.txt b/CHANGES.txt index 9b38023f1076..9aa14cf0184f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -130,6 +130,7 @@ Release 0.90.2 - Unreleased HBASE-3572 memstore lab can leave half inited data structs (bad!) HBASE-3589 test jar should not include mapred-queues.xml and log4j.properties + HBASE-3591 completebulkload doesn't honor generic -D options IMPROVEMENTS HBASE-3542 MultiGet methods in Thrift diff --git a/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java b/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java index 88c4b2f75f91..cdc3d91cefc8 100644 --- a/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java +++ b/src/main/java/org/apache/hadoop/hbase/mapreduce/LoadIncrementalHFiles.java @@ -308,7 +308,7 @@ public int run(String[] args) throws Exception { } Path hfofDir = new Path(args[0]); - HTable table = new HTable(args[1]); + HTable table = new HTable(this.getConf(), args[1]); doBulkLoad(hfofDir, table); return 0;
482fb8025a05eb3763648c9e20c42eef1a9e787b
Valadoc
libvaladoc: Improve plugin selection (#676453)
a
https://github.com/GNOME/vala/
diff --git a/src/libvaladoc/moduleloader.vala b/src/libvaladoc/moduleloader.vala index 9ac5d7b9ed..a4e8697b38 100644 --- a/src/libvaladoc/moduleloader.vala +++ b/src/libvaladoc/moduleloader.vala @@ -75,12 +75,17 @@ public class Valadoc.ModuleLoader : Object { return FileUtils.test (path, FileTest.EXISTS) && FileUtils.test (library_path, FileTest.EXISTS); } + public static bool is_doclet (string path) { + string library_path = Path.build_filename (path, "libdoclet." + Module.SUFFIX); + return FileUtils.test (path, FileTest.EXISTS) && FileUtils.test (library_path, FileTest.EXISTS); + } + private static string get_plugin_path (string pluginpath, string pluginsubdir) { if (Path.is_absolute (pluginpath) == false) { // Test to see if the plugin exists in the expanded path and then fallback // to using the configured plugin directory string local_path = Path.build_filename (Environment.get_current_dir(), pluginpath); - if (FileUtils.test(local_path, FileTest.EXISTS)) { + if (is_doclet(local_path)) { return local_path; } else { return Path.build_filename (Config.plugin_dir, pluginsubdir, pluginpath);
d76b92301dc359a81820d383d8f0661fb3273168
Vala
gdk-2.0: Mark Gdk.Region.get_rectangles rectangles param as out Fixes bug 612632.
c
https://github.com/GNOME/vala/
diff --git a/vapi/gdk-2.0.vapi b/vapi/gdk-2.0.vapi index 332b11eb01..54406a4d59 100644 --- a/vapi/gdk-2.0.vapi +++ b/vapi/gdk-2.0.vapi @@ -415,7 +415,7 @@ namespace Gdk { public bool empty (); public bool equal (Gdk.Region region2); public void get_clipbox (out Gdk.Rectangle rectangle); - public void get_rectangles (Gdk.Rectangle[] rectangles); + public void get_rectangles (out Gdk.Rectangle[] rectangles); public void intersect (Gdk.Region source2); public void offset (int dx, int dy); public bool point_in (int x, int y); diff --git a/vapi/packages/gdk-2.0/gdk-2.0.metadata b/vapi/packages/gdk-2.0/gdk-2.0.metadata index 68669dd3ba..c9980df9a2 100644 --- a/vapi/packages/gdk-2.0/gdk-2.0.metadata +++ b/vapi/packages/gdk-2.0/gdk-2.0.metadata @@ -84,6 +84,7 @@ GdkRectangle is_value_type="1" gdk_rectangle_union.dest is_out="1" gdk_region_copy transfer_ownership="1" gdk_region_get_clipbox.rectangle is_out="1" +gdk_region_get_rectangles.rectangles is_array="1" is_out="1" transfer_ownership="1" gdk_region_rectangle transfer_ownership="1" gdk_region_polygon transfer_ownership="1" gdk_rgb_find_color.color is_ref="1"
130a91a2d393bc9a0128cc2fafa3e52c6528e005
Mylyn Reviews
bug 380843: index commit messages of changesets Added an initial implementation of an index for the scm repositories. The commit message, the revision and repository url are indexed, which allows to search for all commits for a task in specific repositories. Currently, the index is rebuild at the startup, which limits its use only for smaller git projects. This should be fixed in the near future, when a notification of repository changes is implemented, as well as a mechanism, which determines if the repository has changed while eclipse was not running. Change-Id: If7aebd06dd9ca19090b2af3b5f447fe8454df7d0
a
https://github.com/eclipse-mylyn/org.eclipse.mylyn.reviews
diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/META-INF/MANIFEST.MF b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/META-INF/MANIFEST.MF index fafe890a..c20a3f9c 100644 --- a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/META-INF/MANIFEST.MF +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/META-INF/MANIFEST.MF @@ -2,14 +2,19 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.mylyn.versions.tasks.mapper.generic;singleton:=true -Bundle-Version: 0.1.0.qualifier +Bundle-Version: 1.0.0.qualifier Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.mylyn.tasks.core;bundle-version="3.8.0", org.eclipse.mylyn.versions.core;bundle-version="1.0.0", org.eclipse.mylyn.versions.tasks.ui, org.eclipse.core.runtime, org.eclipse.core.resources, + org.eclipse.mylyn.versions.tasks.core;bundle-version="1.0.0", org.eclipse.mylyn.tasks.ui;bundle-version="3.8.0", - org.eclipse.mylyn.versions.tasks.core;bundle-version="1.0.0" -Export-Package: org.eclipse.mylyn.versions.tasks.mapper.generic;x-internal:=true + org.apache.lucene.core;bundle-version="2.9.1", + org.eclipse.team.core;bundle-version="3.6.0" +Export-Package: org.eclipse.mylyn.versions.tasks.mapper.generic;x-internal:=true, + org.eclipse.mylyn.versions.tasks.mapper.internal Bundle-Vendor: %Bundle-Vendor +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.mylyn.versions.tasks.mapper.internal.RepositoryIndexerPlugin diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/pom.xml b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/pom.xml index 44e42970..71e4552a 100644 --- a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/pom.xml +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/pom.xml @@ -5,10 +5,11 @@ <parent> <artifactId>mylyn-reviews-tasks-parent</artifactId> <groupId>org.eclipse.mylyn.reviews</groupId> - <version>0.7.0-SNAPSHOT</version> + <version>1.0.0-SNAPSHOT</version> </parent> + <groupId>org.eclipse.mylyn.reviews</groupId> <artifactId>org.eclipse.mylyn.versions.tasks.mapper.generic</artifactId> - <version>0.1.0-SNAPSHOT</version> + <version>1.0.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <build> <plugins> diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/GenericTaskChangesetMapper.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/GenericTaskChangesetMapper.java index 6c3d230b..3cbe23b9 100644 --- a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/GenericTaskChangesetMapper.java +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/GenericTaskChangesetMapper.java @@ -10,22 +10,34 @@ *******************************************************************************/ package org.eclipse.mylyn.versions.tasks.mapper.generic; +import java.io.File; +import java.io.NotSerializableException; +import java.net.URI; import java.util.ArrayList; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IStorage; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; import org.eclipse.mylyn.tasks.core.ITask; import org.eclipse.mylyn.versions.core.ChangeSet; import org.eclipse.mylyn.versions.core.ScmCore; import org.eclipse.mylyn.versions.core.ScmRepository; import org.eclipse.mylyn.versions.core.spi.ScmConnector; import org.eclipse.mylyn.versions.tasks.core.IChangeSetMapping; +import org.eclipse.mylyn.versions.tasks.mapper.internal.ChangeSetIndexer; +import org.eclipse.mylyn.versions.tasks.mapper.internal.RepositoryIndexerPlugin; import org.eclipse.mylyn.versions.tasks.ui.AbstractChangesetMappingProvider; +import org.eclipse.team.core.history.IFileRevision; +import org.eclipse.team.core.history.ITag; +import org.eclipse.team.core.history.provider.FileRevision; /** * @@ -36,44 +48,98 @@ public class GenericTaskChangesetMapper extends AbstractChangesetMappingProvider { private IConfiguration configuration; + private IChangeSetIndexSearcher indexSearch; public GenericTaskChangesetMapper() { this.configuration = new EclipsePluginConfiguration(); - + this.indexSearch = RepositoryIndexerPlugin.getDefault().getIndexer(); } public GenericTaskChangesetMapper(IConfiguration configuration) { this.configuration = configuration; } - public void getChangesetsForTask(IChangeSetMapping mapping, - IProgressMonitor monitor) throws CoreException { + public void getChangesetsForTask(final IChangeSetMapping mapping, + final IProgressMonitor monitor) throws CoreException { ITask task = mapping.getTask(); if (task == null) throw new IllegalArgumentException("task must not be null"); + List<ScmRepository> repos = getRepositoriesFor(task); - for (ScmRepository repo : repos) { - - List<ChangeSet> allChangeSets = repo.getConnector().getChangeSets( - repo, new NullProgressMonitor()); - for (ChangeSet cs : allChangeSets) { - if (changeSetMatches(cs, task)) { - mapping.addChangeSet(cs); - } - } + for (final ScmRepository repo : repos) { + indexSearch.search(task, repo.getUrl(), 10, new IChangeSetCollector() { + + public void collect(String revision, String repositoryUrl) throws CoreException { + mapping.addChangeSet(getChangeset(revision, repo,monitor)); + } + }); } } - private boolean changeSetMatches(ChangeSet cs, ITask task) { - // FIXME better detection - return cs.getMessage().contains(task.getTaskKey()) - || cs.getMessage().contains(task.getUrl()); + class FileRevision implements IFileRevision{ + private String contentIdentifier; + + public FileRevision(String contentIdentifier){ + this.contentIdentifier=contentIdentifier; + } + + public IStorage getStorage(IProgressMonitor monitor) + throws CoreException { + throw new UnsupportedOperationException(); + } + + public String getName() { + throw new UnsupportedOperationException(); + } + + public URI getURI() { + throw new UnsupportedOperationException(); + } + + public long getTimestamp() { + throw new UnsupportedOperationException(); + } + + public boolean exists() { + throw new UnsupportedOperationException(); + } + + public String getContentIdentifier() { + return contentIdentifier; + } + + public String getAuthor() { + throw new UnsupportedOperationException(); + } + + public String getComment() { + throw new UnsupportedOperationException(); + } + + public ITag[] getBranches() { + throw new UnsupportedOperationException(); + } + + public ITag[] getTags() { + throw new UnsupportedOperationException(); + } + + public boolean isPropertyMissing() { + throw new UnsupportedOperationException(); + } + + public IFileRevision withAllProperties(IProgressMonitor monitor) + throws CoreException { + throw new UnsupportedOperationException(); + }} + + protected ChangeSet getChangeset(String revision, ScmRepository repo,IProgressMonitor monitor) throws CoreException { + return repo.getConnector().getChangeSet(repo, new FileRevision(revision), monitor); } private List<ScmRepository> getRepositoriesFor(ITask task) throws CoreException { - Set<ScmRepository> repos = new HashSet<ScmRepository>(); List<IProject> projects = configuration.getProjectsForTaskRepository( diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetCollector.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetCollector.java new file mode 100644 index 00000000..394c83d6 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetCollector.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.generic; + +import org.eclipse.core.runtime.CoreException; +/** + * + * @author Kilian Matt + * + */ +public interface IChangeSetCollector { + + void collect(String revision, String repositoryUrl) throws CoreException; + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetIndexSearcher.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetIndexSearcher.java new file mode 100644 index 00000000..c616f7ac --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetIndexSearcher.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.generic; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.mylyn.tasks.core.ITask; + +/** + * + * @author Kilian Matt + * + */ +public interface IChangeSetIndexSearcher { + + public int search(ITask task, String scmRepositoryUrl, int resultsLimit, + IChangeSetCollector collector) throws CoreException; + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/TaskChangeSet.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetIndexer.java similarity index 65% rename from tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/TaskChangeSet.java rename to tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetIndexer.java index c3c69a1a..1ea42546 100644 --- a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/TaskChangeSet.java +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetIndexer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Research Group for Industrial Software (INSO), Vienna University of Technology. + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,8 +9,6 @@ * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation *******************************************************************************/ package org.eclipse.mylyn.versions.tasks.mapper.generic; - -import org.eclipse.mylyn.tasks.core.ITask; import org.eclipse.mylyn.versions.core.ChangeSet; /** @@ -18,20 +16,8 @@ * @author Kilian Matt * */ -public class TaskChangeSet { - private ChangeSet changeset; - private ITask task; - - public TaskChangeSet(ITask task, ChangeSet cs) { - this.task = task; - this.changeset = cs; - } +public interface IChangeSetIndexer { - public ChangeSet getChangeset() { - return changeset; - } + public void index(ChangeSet changeset); - public ITask getTask() { - return task; - } } diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetSource.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetSource.java new file mode 100644 index 00000000..ab0a6334 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IChangeSetSource.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.generic; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +/** + * + * @author Kilian Matt + * + */ +public interface IChangeSetSource{ + + void fetchAllChangesets(IProgressMonitor monitor, IChangeSetIndexer indexer) throws CoreException; + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangeSetIndexer.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangeSetIndexer.java new file mode 100644 index 00000000..24e7ed98 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangeSetIndexer.java @@ -0,0 +1,163 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.internal; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.apache.lucene.LucenePackage; +import org.apache.lucene.analysis.KeywordAnalyzer; +import org.apache.lucene.analysis.PerFieldAnalyzerWrapper; +import org.apache.lucene.analysis.standard.StandardAnalyzer; +import org.apache.lucene.document.Document; +import org.apache.lucene.document.Field; +import org.apache.lucene.document.Field.Store; +import org.apache.lucene.index.CorruptIndexException; +import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.IndexWriter.MaxFieldLength; +import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanQuery; +import org.apache.lucene.search.DisjunctionMaxQuery; +import org.apache.lucene.search.IndexSearcher; +import org.apache.lucene.search.PhraseQuery; +import org.apache.lucene.search.PrefixQuery; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.ScoreDoc; +import org.apache.lucene.search.TermQuery; +import org.apache.lucene.search.TopDocs; +import org.apache.lucene.search.BooleanClause.Occur; +import org.apache.lucene.search.spans.SpanOrQuery; +import org.apache.lucene.search.spans.SpanQuery; +import org.apache.lucene.search.spans.SpanTermQuery; +import org.apache.lucene.store.NIOFSDirectory; +import org.apache.lucene.util.Version; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.mylyn.tasks.core.ITask; +import org.eclipse.mylyn.versions.core.ChangeSet; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetCollector; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetIndexSearcher; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetIndexer; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetSource; + +/** + * + * @author Kilian Matt + * + */ +public class ChangeSetIndexer implements IChangeSetIndexSearcher { + + private IChangeSetSource source; + + private File indexDirectory; + private IndexWriter indexWriter; + private IndexReader indexReader; + + public ChangeSetIndexer(File directory, IChangeSetSource source) { + this.indexDirectory = directory; + this.source = source; + } + + public void reindex(IProgressMonitor monitor) { + try { + PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new StandardAnalyzer(Version.LUCENE_CURRENT)); + analyzer.addAnalyzer(IndexedFields.REPOSITORY.getIndexKey(), new KeywordAnalyzer()); + indexWriter = new IndexWriter(new NIOFSDirectory(indexDirectory), + analyzer, true, MaxFieldLength.UNLIMITED); + + IChangeSetIndexer indexer = new IChangeSetIndexer() { + + public void index(ChangeSet changeset) { + try { + Document document = new Document(); + for (IndexedFields field : IndexedFields.values()) { + document.add(new Field(field.getIndexKey(), field.getAccessor().getValue(changeset), + Store.YES, Field.Index.ANALYZED)); + } + indexWriter.addDocument(document); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + }; + source.fetchAllChangesets(monitor, indexer); + indexWriter.close(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + public int search(ITask task, String scmRepositoryUrl, int resultsLimit, IChangeSetCollector collector) throws CoreException { + int count = 0; + IndexReader indexReader = getIndexReader(); + if (indexReader != null) { + IndexSearcher indexSearcher = new IndexSearcher(indexReader); + try { + Query query = createQuery(task,scmRepositoryUrl); + TopDocs results = indexSearcher.search(query, resultsLimit); + for (ScoreDoc scoreDoc : results.scoreDocs) { + Document document = indexReader.document(scoreDoc.doc); + count++; + if(count > resultsLimit) + break; + + + String revision = document.getField(IndexedFields.REVISION.getIndexKey()).stringValue(); + String repositoryUrl =document.getField(IndexedFields.REPOSITORY.getIndexKey()).stringValue(); + + collector.collect(revision, repositoryUrl); + } + } catch (IOException e) { +// StatusHandler.log(new Status(IStatus.ERROR, org.eclipse.mylyn.versions.tasks.ui.internal.TaPLUGIN_ID, +//"Unexpected failure within task list index", e)); //$NON-NLS-1$ + } finally { + try { + indexSearcher.close(); + } catch (IOException e) { + // ignore + } + } + } + return count; + + } + + private Query createQuery(ITask task, String repositoryUrl) { + BooleanQuery query =new BooleanQuery(); + query.setMinimumNumberShouldMatch(1); + query.add(new TermQuery(new Term(IndexedFields.REPOSITORY.getIndexKey(),repositoryUrl)),Occur.MUST); + query.add(new PrefixQuery(new Term(IndexedFields.COMMIT_MESSAGE.getIndexKey(),task.getUrl())),Occur.SHOULD); + query.add(new PrefixQuery(new Term(IndexedFields.COMMIT_MESSAGE.getIndexKey(),task.getTaskId())),Occur.SHOULD); + return query; + } + + + private IndexReader getIndexReader() { + try { + synchronized (this) { + if (indexReader == null) { + indexReader = IndexReader.open(new NIOFSDirectory(indexDirectory), true); + } + return indexReader; + } + } catch (CorruptIndexException e) { + // rebuild index + } catch (FileNotFoundException e) { + // rebuild index + } catch (IOException e) { + // ignore + } + return null; + } + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangesetPropertyAccess.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangesetPropertyAccess.java new file mode 100644 index 00000000..91c5ed75 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangesetPropertyAccess.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.internal; +import org.eclipse.mylyn.versions.core.ChangeSet; + +/** + * + * @author Kilian Matt + * + */ +public enum ChangesetPropertyAccess { + + REVISION() { + public String getValue(ChangeSet cs) { + return cs.getId(); + } + }, + REPOSITORY() { + public String getValue(ChangeSet cs) { + return cs.getRepository().getUrl(); + } + }, + COMMIT_MESSAGE() { + public String getValue(ChangeSet cs) { + return cs.getMessage(); + } + }; + + public abstract String getValue(ChangeSet cs); + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/EclipseWorkspaceRepositorySource.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/EclipseWorkspaceRepositorySource.java new file mode 100644 index 00000000..5a05735e --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/EclipseWorkspaceRepositorySource.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.internal; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.mylyn.versions.core.ChangeSet; +import org.eclipse.mylyn.versions.core.ScmCore; +import org.eclipse.mylyn.versions.core.ScmRepository; +import org.eclipse.mylyn.versions.core.spi.ScmConnector; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetIndexer; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetSource; +/** + * + * @author Kilian Matt + * + */ +public class EclipseWorkspaceRepositorySource implements IChangeSetSource { + public void fetchAllChangesets(IProgressMonitor monitor, + IChangeSetIndexer indexer) throws CoreException { + Set<ScmRepository> repositories = new HashSet<ScmRepository>(); + + for (IProject project : ResourcesPlugin.getWorkspace().getRoot() + .getProjects()) { + ScmConnector connector = ScmCore.getConnector(project); + if(connector!=null) { + repositories.add(connector.getRepository(project, monitor)); + } + } + + for (ScmRepository repo : repositories) { + List<ChangeSet> changesets; + changesets = repo.getConnector().getChangeSets(repo, monitor); + for (ChangeSet cs : changesets) { + indexer.index(cs); + } + } + + } +} \ No newline at end of file diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/IndexedFields.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/IndexedFields.java new file mode 100644 index 00000000..82f38d72 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/IndexedFields.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.internal; +import org.eclipse.core.runtime.Assert; + +/** + * + * @author Kilian Matt + * + */ +public enum IndexedFields { + REVISION("revision", ChangesetPropertyAccess.REVISION), + REPOSITORY("repositoryUrl", ChangesetPropertyAccess.REPOSITORY), + COMMIT_MESSAGE("message", ChangesetPropertyAccess.COMMIT_MESSAGE), + ; + + private final String indexKey; + private final ChangesetPropertyAccess accessor; + + IndexedFields(String indexKey, ChangesetPropertyAccess accessor) { + this.indexKey = indexKey; + this.accessor = accessor; + Assert.isNotNull(indexKey); + Assert.isNotNull(accessor); + } + + public String getIndexKey() { + return indexKey; + } + + public ChangesetPropertyAccess getAccessor() { + return accessor; + } + +} \ No newline at end of file diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/RepositoryIndexer.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/RepositoryIndexer.java new file mode 100644 index 00000000..ecea2908 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/RepositoryIndexer.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.internal; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetIndexSearcher; +/** + * + * @author Kilian Matt + * + */ +public class RepositoryIndexer { + + private IndexRepositoryJob repoSyncJob; + + public RepositoryIndexer() { + + repoSyncJob = new IndexRepositoryJob(); + repoSyncJob.schedule(10000); + } + + private static class IndexRepositoryJob extends Job { + + public IndexRepositoryJob() { + super("Indexing repositories."); + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + IChangeSetIndexSearcher indexer = RepositoryIndexerPlugin.getDefault().getIndexer(); + ((ChangeSetIndexer)indexer).reindex(monitor); + + return new Status(IStatus.OK, RepositoryIndexerPlugin.PLUGIN_ID, + "Indexing finished"); + } + + } + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/RepositoryIndexerPlugin.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/RepositoryIndexerPlugin.java new file mode 100644 index 00000000..72872649 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.generic/src/org/eclipse/mylyn/versions/tasks/mapper/internal/RepositoryIndexerPlugin.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.internal; + +import java.io.File; + +import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetIndexSearcher; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +/** + * + * @author Kilian Matt + * + */ +public class RepositoryIndexerPlugin implements BundleActivator { + private static RepositoryIndexerPlugin instance; + public static final String PLUGIN_ID="org.eclipse.mylyn.versions.tasks.mapper"; + + private RepositoryIndexer synchronizer; + private IChangeSetIndexSearcher indexSearch; + + public RepositoryIndexerPlugin() { + instance = this; + } + + public static RepositoryIndexerPlugin getDefault() { + return instance; + } + + public void start(BundleContext context) throws Exception { + synchronizer= new RepositoryIndexer(); + + File file = new File(TasksUiPlugin.getDefault().getDataDirectory(),".changeSetIndex"); + indexSearch=new ChangeSetIndexer(file,new EclipseWorkspaceRepositorySource()); + } + public IChangeSetIndexSearcher getIndexer(){ + return indexSearch; + } + + public void stop(BundleContext context) throws Exception { + this.instance=null; + + } + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/.classpath b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/.classpath new file mode 100644 index 00000000..ad32c83a --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/.project b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/.project new file mode 100644 index 00000000..6f619447 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.mylyn.versions.tasks.mapper.tests</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/META-INF/MANIFEST.MF b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/META-INF/MANIFEST.MF new file mode 100644 index 00000000..ad4ffef5 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Task Mapper Tests +Bundle-SymbolicName: org.eclipse.mylyn.versions.tasks.mapper.tests +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.junit;bundle-version="4.8.2", + org.eclipse.mylyn.versions.tasks.mapper.generic;bundle-version="0.1.0", + org.eclipse.mylyn.versions.core;bundle-version="1.0.0", + org.eclipse.core.runtime;bundle-version="3.7.0", + org.eclipse.mylyn.tasks.core;bundle-version="3.8.0", + org.eclipse.mylyn.tasks.tests;bundle-version="3.8.0" diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/about.html b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/about.html new file mode 100644 index 00000000..d774b07c --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/about.html @@ -0,0 +1,27 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<head> +<title>About</title> +<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1"> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>June 25, 2008</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, &quot;Program&quot; will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="/">http://www.eclipse.org</a>.</p> + +</body> +</html> \ No newline at end of file diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/build.properties b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/build.properties new file mode 100644 index 00000000..34d2e4d2 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/pom.xml b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/pom.xml new file mode 100644 index 00000000..f747fa78 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/pom.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>mylyn-reviews-tasks-parent</artifactId> + <groupId>org.eclipse.mylyn.reviews</groupId> + <version>1.0.0-SNAPSHOT</version> + </parent> + <groupId>org.eclipse.mylyn.reviews</groupId> + <artifactId>org.eclipse.mylyn.versions.tasks.mapper.tests</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-source-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>findbugs-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + </plugin> + </plugins> + </build> +</project> diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IndexTest.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IndexTest.java new file mode 100644 index 00000000..311cb582 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/generic/IndexTest.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.generic; +import org.junit.Test; + +/** + * + * @author Kilian Matt + * + */ +public class IndexTest { + + @Test + public void testIndexCreation(){ + + } +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangeSetIndexerTest.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangeSetIndexerTest.java new file mode 100644 index 00000000..f909b736 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangeSetIndexerTest.java @@ -0,0 +1,150 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.internal; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.mylyn.tasks.core.ITask; +import org.eclipse.mylyn.tasks.tests.connector.MockTask; +import org.eclipse.mylyn.versions.core.Change; +import org.eclipse.mylyn.versions.core.ChangeSet; +import org.eclipse.mylyn.versions.core.ScmRepository; +import org.eclipse.mylyn.versions.core.ScmUser; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetCollector; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetIndexer; +import org.eclipse.mylyn.versions.tasks.mapper.generic.IChangeSetSource; +import org.junit.Before; +import org.junit.Test; + +/** + * + * @author Kilian Matt + * + */ +public class ChangeSetIndexerTest { + + protected static final String REPO_URL = "http://git.eclipse.org/c/mylyn/org.eclipse.mylyn.versions.git"; + private ChangeSetIndexer indexer; + + @Before + public void prepareIndex() { + File dir = createTempDirectoryForIndex(); + + indexer = new ChangeSetIndexer(dir, createIndexerSource()); + indexer.reindex(new NullProgressMonitor()); + } + + @Test + public void testSingleResult() throws CoreException{ + ITask task = new MockTask(REPO_URL,"1"); + task.setUrl(REPO_URL+"/1"); + ExpectingChangeSetCollector collectors= new ExpectingChangeSetCollector(); + collectors.expect("1", REPO_URL); + assertEquals(1, indexer.search(task,REPO_URL, 5,collectors)); + collectors.verifyAllExpectations(); + } + @Test + public void testMultipleResults() throws CoreException{ + ITask task = new MockTask(REPO_URL,"2"); + task.setUrl(REPO_URL+"/1"); + ExpectingChangeSetCollector collectors= new ExpectingChangeSetCollector(); + collectors.expect("2", REPO_URL); + collectors.expect("3", REPO_URL); + assertEquals(2, indexer.search(task,REPO_URL, 5,collectors)); + collectors.verifyAllExpectations(); + } + + + static class ExpectingChangeSetCollector implements IChangeSetCollector{ + private List<Pair> expected=new LinkedList<Pair>(); + void expect(String revision, String repositoryUrl){ + this.expected.add(new Pair(revision,repositoryUrl)); + } + + public void verifyAllExpectations() { + if(expected.size()>0){ + fail( expected.size() + " expected changesets not collected"); + } + } + + private static class Pair{ + Pair(String rev, String repoUrl){ + this.rev=rev; + this.repoUrl=repoUrl; + } + final String rev; + final String repoUrl; + } + + @Override + public void collect(String revision, String repositoryUrl) + throws CoreException { + if(expected.size()==0){ + fail("unexpected changeset"); + } + Pair first = expected.remove(0); + assertEquals(first.rev, revision); + assertEquals(first.repoUrl, repositoryUrl); + } + } + private ListChangeSetSource createIndexerSource() { + ScmRepository repository=new ScmRepository(null, "", REPO_URL); + ScmRepository otherRepo=new ScmRepository(null, "", "http://git.eclipse.org/c/mylyn/org.eclipse.mylyn.reviews.git"); + ListChangeSetSource source = new ListChangeSetSource(Arrays.asList( + new ChangeSet(new ScmUser("test", "Name", "[email protected]"), new Date(), "1", "commit message 1", repository, new ArrayList<Change>()), + new ChangeSet(new ScmUser("test", "Name", "[email protected]"), new Date(), "1", "commit message 1", otherRepo, new ArrayList<Change>()), + new ChangeSet(new ScmUser("test", "Name", "[email protected]"), new Date(), "2", "commit message 2", repository, new ArrayList<Change>()), + new ChangeSet(new ScmUser("test", "Name", "[email protected]"), new Date(), "3", "commit message 2", repository, new ArrayList<Change>()) + )); + return source; + } + + class ListChangeSetSource implements IChangeSetSource { + private List<ChangeSet> changesets; + public ListChangeSetSource(List<ChangeSet> changesets){ + this.changesets=changesets; + } + @Override + public void fetchAllChangesets(IProgressMonitor monitor, + IChangeSetIndexer indexer) throws CoreException { + for(ChangeSet changeset : changesets){ + indexer.index(changeset); + } + } + } + + private File createTempDirectoryForIndex() { + File dir = null; + try { + dir = File.createTempFile("test","dasd"); + dir.delete(); + dir.mkdir(); + dir.deleteOnExit(); + } catch (IOException e) { + throw new RuntimeException(e); + } + return dir; + } + + + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangesetPropertyAccessTest.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangesetPropertyAccessTest.java new file mode 100644 index 00000000..1ba01552 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/internal/ChangesetPropertyAccessTest.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.internal; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.Date; + +import org.eclipse.mylyn.versions.core.Change; +import org.eclipse.mylyn.versions.core.ChangeSet; +import org.eclipse.mylyn.versions.core.ScmRepository; +import org.junit.Before; +import org.junit.Test; +/** + * + * @author Kilian Matt + * + */ +public class ChangesetPropertyAccessTest { + + private ChangeSet cs; + final String expectedId = "123"; + final String expectedMessage = "Sample Message"; + final String expectedRepository = "git://git.eclipse.org/c/mylyn/org.eclipse.versions.git"; + + @Before + public void prepare() { + cs = new ChangeSet(null, new Date(), expectedId, expectedMessage, new ScmRepository(null, "test", expectedRepository), + new ArrayList<Change>()); + } + + @Test + public void testRevisionAccess() { + assertEquals(expectedId, ChangesetPropertyAccess.REVISION.getValue(cs)); + } + + @Test + public void testCommitMessageAccess() { + assertEquals(expectedMessage, + ChangesetPropertyAccess.COMMIT_MESSAGE.getValue(cs)); + } + + @Test + public void testRepositoryAccess() { + assertEquals(expectedRepository, + ChangesetPropertyAccess.REPOSITORY.getValue(cs)); + } + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/internal/IndexedFieldsTest.java b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/internal/IndexedFieldsTest.java new file mode 100644 index 00000000..c815b332 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.mapper.tests/src/org/eclipse/mylyn/versions/tasks/mapper/internal/IndexedFieldsTest.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.mapper.internal; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.util.Set; +import java.util.TreeSet; + +import org.junit.Test; + +/** + * + * @author Kilian Matt + * + */ +public class IndexedFieldsTest { + + @Test + public void indexKeyIsUnique(){ + Set<String > fields = new TreeSet<String>(); + for(IndexedFields f : IndexedFields.values()){ + String indexKey = f.getIndexKey(); + assertNotNull(indexKey); + if(fields.contains(indexKey)){ + fail("Duplicate Index key " + indexKey); + } + fields.add(indexKey); + } + } + +} diff --git a/tbr/org.eclipse.mylyn.versions.tasks.ui/META-INF/MANIFEST.MF b/tbr/org.eclipse.mylyn.versions.tasks.ui/META-INF/MANIFEST.MF index 85ce1716..ae1f7447 100644 --- a/tbr/org.eclipse.mylyn.versions.tasks.ui/META-INF/MANIFEST.MF +++ b/tbr/org.eclipse.mylyn.versions.tasks.ui/META-INF/MANIFEST.MF @@ -16,3 +16,4 @@ Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.eclipse.mylyn.versions.tasks.ui;x-internal:=true Bundle-Vendor: %Bundle-Vendor +Bundle-Activator: org.eclipse.mylyn.versions.tasks.ui.internal.TaskVersionsUiPlugin diff --git a/tbr/org.eclipse.mylyn.versions.tasks.ui/src/org/eclipse/mylyn/versions/tasks/ui/internal/TaskVersionsUiPlugin.java b/tbr/org.eclipse.mylyn.versions.tasks.ui/src/org/eclipse/mylyn/versions/tasks/ui/internal/TaskVersionsUiPlugin.java new file mode 100644 index 00000000..1946de09 --- /dev/null +++ b/tbr/org.eclipse.mylyn.versions.tasks.ui/src/org/eclipse/mylyn/versions/tasks/ui/internal/TaskVersionsUiPlugin.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2012 Research Group for Industrial Software (INSO), Vienna University of Technology. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Research Group for Industrial Software (INSO), Vienna University of Technology - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylyn.versions.tasks.ui.internal; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * + * @author Kilian Matt + * + */ +public class TaskVersionsUiPlugin extends AbstractUIPlugin { + private static TaskVersionsUiPlugin instance; + public static final String PLUGIN_ID="org.eclipse.mylyn.versions.tasks.ui"; + + public TaskVersionsUiPlugin() { + instance = this; + } + + public static TaskVersionsUiPlugin getDefault() { + return instance; + } + +} diff --git a/tbr/pom.xml b/tbr/pom.xml index 1b587c31..2f936dcf 100644 --- a/tbr/pom.xml +++ b/tbr/pom.xml @@ -18,5 +18,7 @@ <module>org.eclipse.mylyn.reviews.tasks.ui</module> <module>org.eclipse.mylyn.versions.tasks.core</module> <module>org.eclipse.mylyn.versions.tasks.ui</module> + <module>org.eclipse.mylyn.versions.tasks.mapper.generic</module> + <module>org.eclipse.mylyn.versions.tasks.mapper.tests</module> </modules> </project>
1e6e05830c8eb3f482ae40016879c7a835697b8b
arquillian$arquillian-graphene
ARQGRA-464 @Page method param injection - added support for @InFrame
a
https://github.com/arquillian/arquillian-graphene
diff --git a/api/src/main/java/org/jboss/arquillian/graphene/page/InFrame.java b/api/src/main/java/org/jboss/arquillian/graphene/page/InFrame.java index 638711a61..1e0675317 100644 --- a/api/src/main/java/org/jboss/arquillian/graphene/page/InFrame.java +++ b/api/src/main/java/org/jboss/arquillian/graphene/page/InFrame.java @@ -39,7 +39,7 @@ * @author Juraj Huska */ @Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) +@Target({ElementType.FIELD, ElementType.PARAMETER}) public @interface InFrame { /** diff --git a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/FieldAccessValidatorEnricher.java b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/FieldAccessValidatorEnricher.java index e02a418a8..827d9d6c4 100644 --- a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/FieldAccessValidatorEnricher.java +++ b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/FieldAccessValidatorEnricher.java @@ -62,8 +62,8 @@ protected void checkFieldValidity(final SearchContext searchContext, final Objec } @Override - public Object[] resolve(SearchContext searchContext, Method method) { - return new Object[method.getParameterTypes().length]; + public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { + return resolvedParams; } @Override diff --git a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/GrapheneEnricher.java b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/GrapheneEnricher.java index 9639fb82d..10b9841f4 100644 --- a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/GrapheneEnricher.java +++ b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/GrapheneEnricher.java @@ -77,12 +77,7 @@ public Object[] resolve(Method method) { for (SearchContextTestEnricher enricher : sortedSearchContextEnrichers) { if (isApplicableToTestClass(enricher)) { - Object[] resolved = enricher.resolve(null, method); - for (int i = 0; i < resolvedParams.length; i++) { - if (resolved[i] != null) { - resolvedParams[i] = resolved[i]; - } - } + resolvedParams = enricher.resolve(null, method, resolvedParams); } } return resolvedParams; diff --git a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/InFrameEnricher.java b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/InFrameEnricher.java index 5cd5227bc..5906cd1a8 100644 --- a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/InFrameEnricher.java +++ b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/InFrameEnricher.java @@ -21,9 +21,12 @@ */ package org.jboss.arquillian.graphene.enricher; +import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Collection; +import java.util.LinkedList; +import java.util.List; import org.jboss.arquillian.graphene.enricher.exception.GrapheneTestEnricherException; import org.jboss.arquillian.graphene.page.InFrame; @@ -64,14 +67,43 @@ public void enrich(SearchContext searchContext, Object objectToEnrich) { } @Override - public Object[] resolve(SearchContext searchContext, Method method) { - return new Object[method.getParameterTypes().length]; + public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { + StringBuffer errorMsgBegin = new StringBuffer(""); + List<Object[]> paramCouple = new LinkedList<Object[]>(); + paramCouple.addAll(ReflectionHelper.getParametersWithAnnotation(method, InFrame.class)); + + for (int i = 0; i < resolvedParams.length; i++) { + if (paramCouple.get(i) != null && resolvedParams[i] != null) { + Class<?> param = (Class<?>) paramCouple.get(i)[0]; + Annotation[] parameterAnnotations = (Annotation[]) paramCouple.get(i)[1]; + InFrame inFrame = ReflectionHelper.findAnnotation(parameterAnnotations, InFrame.class); + int index = inFrame.index(); + String nameOrId = inFrame.nameOrId(); + checkInFrameParameters(method, param, index, nameOrId); + + try { + registerInFrameInterceptor((GrapheneProxyInstance) resolvedParams[i], index, nameOrId); + } catch (IllegalArgumentException e) { + throw new GrapheneTestEnricherException( + "Only org.openqa.selenium.WebElement, Page fragments fields and Page Object fields can be annotated with @InFrame. Check parameter " + + param + " of the method: " + method.getName() + " declared in: " + method + .getDeclaringClass(), e); + } catch (Exception e) { + throw new GrapheneTestEnricherException(e); + } + } + } + return resolvedParams; } private void registerInFrameInterceptor(Object objectToEnrich, Field field, int index, String nameOrId) throws IllegalAccessException, ClassNotFoundException { GrapheneProxyInstance proxy = (GrapheneProxyInstance) field.get(objectToEnrich); + registerInFrameInterceptor(proxy, index, nameOrId); + } + + private void registerInFrameInterceptor(GrapheneProxyInstance proxy, int index, String nameOrId) { if (index != -1) { proxy.registerInterceptor(new InFrameInterceptor(index)); } else { @@ -80,13 +112,25 @@ private void registerInFrameInterceptor(Object objectToEnrich, Field field, int } private void checkInFrameParameters(Field field, int index, String nameOrId) { - if ((nameOrId.trim().equals("") && index < 0)) { + if (checkInFrameParameters(index, nameOrId)) { throw new GrapheneTestEnricherException( "You have to provide either non empty nameOrId or non negative index value of the frame/iframe in the @InFrame. Check field " + field + " declared in: " + field.getDeclaringClass()); } } + private void checkInFrameParameters(Method method, Class<?> param, int index, String nameOrId) { + if (checkInFrameParameters(index, nameOrId)) { + throw new GrapheneTestEnricherException( + "You have to provide either non empty nameOrId or non negative index value of the frame/iframe in the @InFrame. Check parameter " + + param + " of the method: " + method.getName() + " declared in: " + method.getDeclaringClass()); + } + } + + private boolean checkInFrameParameters(int index, String nameOrId) { + return nameOrId.trim().equals("") && index < 0; + } + @Override public int getPrecedence() { return 0; diff --git a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/JavaScriptEnricher.java b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/JavaScriptEnricher.java index 0d35ff148..ecf9e1b3d 100644 --- a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/JavaScriptEnricher.java +++ b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/JavaScriptEnricher.java @@ -56,8 +56,8 @@ public void enrich(final SearchContext searchContext, Object target) { } @Override - public Object[] resolve(SearchContext searchContext, Method method) { - return new Object[method.getParameterTypes().length]; + public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { + return resolvedParams; } @Override diff --git a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentEnricher.java b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentEnricher.java index 8521839ed..13bcef02e 100644 --- a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentEnricher.java +++ b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentEnricher.java @@ -98,8 +98,8 @@ public void enrich(final SearchContext searchContext, Object target) { } @Override - public Object[] resolve(SearchContext searchContext, Method method) { - return new Object[method.getParameterTypes().length]; + public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { + return resolvedParams; } protected final boolean isPageFragmentClass(Class<?> clazz, Object target) { diff --git a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageObjectEnricher.java b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageObjectEnricher.java index 90542e943..51eecb7d6 100644 --- a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageObjectEnricher.java +++ b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageObjectEnricher.java @@ -58,23 +58,20 @@ public void enrich(final SearchContext searchContext, Object target) { } @Override - public Object[] resolve(SearchContext searchContext, Method method) { + public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { StringBuffer errorMsgBegin = new StringBuffer(""); List<Object[]> paramCouple = new LinkedList<Object[]>(); paramCouple.addAll(ReflectionHelper.getParametersWithAnnotation(method, Page.class)); - Object[] resolution = new Object[method.getParameterTypes().length]; - for (int i = 0; i < resolution.length; i++) { - if (paramCouple.get(i) == null) { - resolution[i] = null; - } else { + for (int i = 0; i < resolvedParams.length; i++) { + if (paramCouple.get(i) != null) { Class<?> param = (Class<?>) paramCouple.get(i)[0]; Annotation[] parameterAnnotations = (Annotation[]) paramCouple.get(i)[1]; Object page = createPage(searchContext, parameterAnnotations, null, null, method, param); - resolution[i] = page; + resolvedParams[i] = page; } } - return resolution; + return resolvedParams; } private Object createPage(SearchContext searchContext, Annotation[] annotations, Object target, Field field, diff --git a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/ReflectionHelper.java b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/ReflectionHelper.java index 0497f744a..72f7257ba 100644 --- a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/ReflectionHelper.java +++ b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/ReflectionHelper.java @@ -273,11 +273,13 @@ public List<Method> run() { } /** - * Returns all the parameters annotated with the given annotation for the specified method + * Returns all couples of found parameter annotated with the given annotation and an array of all annotations the + * parameter is annotated with for the given method * * @param method - the method where the parameters should be examined * @param annotationClass - the annotation the parameters should be annotated with - * @return list of found parameters annotated with the given annotation + * @return list of couples in an object array that consist of found parameter annotated with the given annotation + * and an array of all annotations the parameter is annotated with */ public static List<Object[]> getParametersWithAnnotation(final Method method, final Class<? extends Annotation> annotationClass) { @@ -324,7 +326,7 @@ private static boolean isAnnotationPresent(final Annotation[] annotations, final * @return the found annotation */ @SuppressWarnings("unchecked") - private static <T extends Annotation> T findAnnotation(final Annotation[] annotations, final Class<T> needle) { + public static <T extends Annotation> T findAnnotation(final Annotation[] annotations, final Class<T> needle) { for (Annotation annotation : annotations) { if (annotation.annotationType() == needle) { return (T) annotation; diff --git a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/WebElementEnricher.java b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/WebElementEnricher.java index e1994ce9e..eaec572e1 100644 --- a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/WebElementEnricher.java +++ b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/WebElementEnricher.java @@ -84,8 +84,8 @@ && getListType(field).isAssignableFrom(WebElement.class)) { } @Override - public Object[] resolve(SearchContext searchContext, Method method) { - return new Object[method.getParameterTypes().length]; + public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { + return resolvedParams; } @Override diff --git a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/WebElementWrapperEnricher.java b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/WebElementWrapperEnricher.java index 0cdafa31f..fb6406143 100644 --- a/impl/src/main/java/org/jboss/arquillian/graphene/enricher/WebElementWrapperEnricher.java +++ b/impl/src/main/java/org/jboss/arquillian/graphene/enricher/WebElementWrapperEnricher.java @@ -122,8 +122,8 @@ public void enrich(final SearchContext searchContext, Object target) { } @Override - public Object[] resolve(SearchContext searchContext, Method method) { - return new Object[method.getParameterTypes().length]; + public Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams) { + return resolvedParams; } protected <T> T createWrapper(GrapheneContext grapheneContext, final Class<T> type, final WebElement element) diff --git a/spi/src/main/java/org/jboss/arquillian/graphene/spi/enricher/SearchContextTestEnricher.java b/spi/src/main/java/org/jboss/arquillian/graphene/spi/enricher/SearchContextTestEnricher.java index 1eb3b8f4e..a50671fce 100644 --- a/spi/src/main/java/org/jboss/arquillian/graphene/spi/enricher/SearchContextTestEnricher.java +++ b/spi/src/main/java/org/jboss/arquillian/graphene/spi/enricher/SearchContextTestEnricher.java @@ -45,11 +45,11 @@ public interface SearchContextTestEnricher { /** * Performs resolve for the given method with the given {@link SearchContext}. - * * @param searchContext the context which should be used for resolve * @param method method to be resolved + * @param resolvedParams parameters that has (not) been resolved so far */ - Object[] resolve(SearchContext searchContext, Method method); + Object[] resolve(SearchContext searchContext, Method method, Object[] resolvedParams); /** * Returns the enricher precedence. Zero precedence is is the lowest one.
a465b2441025ab3b7db8150b06c79f26af60f95e
arquillian$arquillian-graphene
ARQGRA-190: support for initializing page objects with generic types
a
https://github.com/arquillian/arquillian-graphene
diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/AbstractTest.java b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/AbstractTest.java new file mode 100644 index 000000000..80685a575 --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/AbstractTest.java @@ -0,0 +1,29 @@ +package org.jboss.arquillian.graphene.enricher; + +import java.net.URL; + +import org.jboss.arquillian.drone.api.annotation.Drone; +import org.jboss.arquillian.graphene.enricher.page.AbstractPage; +import org.jboss.arquillian.graphene.spi.annotations.Page; +import org.openqa.selenium.WebDriver; + +public abstract class AbstractTest<T extends AbstractPage, E> { + + @Page + protected T pageWithGenericType; + + @Page + protected E anotherPageWithGenericType; + + @Drone + protected WebDriver selenium; + + public void loadPage() { + URL page = this.getClass().getClassLoader() + .getResource("org/jboss/arquillian/graphene/ftest/pageFragmentsEnricher/sample.html"); + + selenium.get(page.toExternalForm()); + } + + +} diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/MoreSpecificAbstractTest.java b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/MoreSpecificAbstractTest.java new file mode 100644 index 000000000..2c1bbe58d --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/MoreSpecificAbstractTest.java @@ -0,0 +1,7 @@ +package org.jboss.arquillian.graphene.enricher; + +import org.jboss.arquillian.graphene.enricher.page.AbstractPage; + +public class MoreSpecificAbstractTest<T extends AbstractPage, E> extends AbstractTest<T, E> { + +} diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/TestInitializingPageObjects1.java b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/TestInitializingPageObjects1.java new file mode 100644 index 000000000..2e6c77d97 --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/TestInitializingPageObjects1.java @@ -0,0 +1,29 @@ +package org.jboss.arquillian.graphene.enricher; + +import static org.junit.Assert.assertEquals; + +import org.jboss.arquillian.graphene.enricher.page.TestPage; +import org.jboss.arquillian.graphene.enricher.page.TestPage2; +import org.jboss.arquillian.junit.Arquillian; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class TestInitializingPageObjects1 extends MoreSpecificAbstractTest<TestPage, TestPage2> { + + private final String EXPECTED_NESTED_ELEMENT_TEXT = "Some Value"; + + @Test + public void testPageObjectWithGenericTypeIsInitialized1() { + loadPage(); + assertEquals("The page object was not set correctly!", pageWithGenericType.getAbstractPageFragment() + .invokeMethodOnElementRefByXpath(), EXPECTED_NESTED_ELEMENT_TEXT); + } + + @Test + public void testPageObjectWithGenericTypeIsInitialized2() { + loadPage(); + assertEquals("The page object was not set correctly!", anotherPageWithGenericType.getAbstractPageFragment() + .invokeMethodOnElementRefByXpath(), EXPECTED_NESTED_ELEMENT_TEXT); + } +} diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/TestInitializingPageObjects2.java b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/TestInitializingPageObjects2.java new file mode 100644 index 000000000..67fd3e535 --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/TestInitializingPageObjects2.java @@ -0,0 +1,29 @@ +package org.jboss.arquillian.graphene.enricher; + +import static org.junit.Assert.assertEquals; + +import org.jboss.arquillian.graphene.enricher.page.TestPage; +import org.jboss.arquillian.graphene.enricher.page.TestPage2; +import org.jboss.arquillian.junit.Arquillian; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class TestInitializingPageObjects2 extends AbstractTest<TestPage, TestPage2> { + + private final String EXPECTED_NESTED_ELEMENT_TEXT = "Some Value"; + + @Test + public void testPageObjectWithGenericTypeIsInitialized1() { + loadPage(); + assertEquals("The page object was not set correctly!", pageWithGenericType.getAbstractPageFragment() + .invokeMethodOnElementRefByXpath(), EXPECTED_NESTED_ELEMENT_TEXT); + } + + @Test + public void testPageObjectWithGenericTypeIsInitialized2() { + loadPage(); + assertEquals("The page object was not set correctly!", anotherPageWithGenericType.getAbstractPageFragment() + .invokeMethodOnElementRefByXpath(), EXPECTED_NESTED_ELEMENT_TEXT); + } +} diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/AbstractPage.java b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/AbstractPage.java new file mode 100644 index 000000000..2d21e86c4 --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/AbstractPage.java @@ -0,0 +1,18 @@ +package org.jboss.arquillian.graphene.enricher.page; + +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +public class AbstractPage { + + @FindBy(xpath = "//input") + private WebElement input; + + public WebElement getInput() { + return input; + } + + public void setInput(WebElement input) { + this.input = input; + } +} diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/TestPage.java b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/TestPage.java index 77314aaaf..f65219d95 100644 --- a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/TestPage.java +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/TestPage.java @@ -29,11 +29,11 @@ /** * @author Juraj Huska */ -public class TestPage { +public class TestPage extends AbstractPage { @FindBy(xpath = "//div[@id='rootElement']") private AbstractPageFragmentStub abstractPageFragment; - + @FindBy(xpath = "//div[@id='rootElement']") private WebElement element; diff --git a/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/TestPage2.java b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/TestPage2.java new file mode 100644 index 000000000..983db9112 --- /dev/null +++ b/graphene-webdriver/graphene-webdriver-ftest/src/test/java/org/jboss/arquillian/graphene/enricher/page/TestPage2.java @@ -0,0 +1,53 @@ +package org.jboss.arquillian.graphene.enricher.page; + +import org.jboss.arquillian.graphene.enricher.AbstractPageFragmentStub; +import org.jboss.arquillian.graphene.spi.annotations.Page; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +public class TestPage2 { + + @FindBy(xpath = "//div[@id='rootElement']") + private AbstractPageFragmentStub abstractPageFragment; + + @FindBy(xpath = "//div[@id='rootElement']") + private WebElement element; + + @FindBy(xpath = "//input") + private WebElement input; + + @Page + private EmbeddedPage embeddedPage; + + public AbstractPageFragmentStub getAbstractPageFragment() { + return abstractPageFragment; + } + + public void setAbstractPageFragment(AbstractPageFragmentStub abstractPageFragment) { + this.abstractPageFragment = abstractPageFragment; + } + + public WebElement getElement() { + return element; + } + + public void setElement(WebElement element) { + this.element = element; + } + + public WebElement getInput() { + return input; + } + + public void setInput(WebElement input) { + this.input = input; + } + + public EmbeddedPage getEmbeddedPage() { + return embeddedPage; + } + + public void setEmbeddedPage(EmbeddedPage embeddedPage) { + this.embeddedPage = embeddedPage; + } +} diff --git a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/Factory.java b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/Factory.java index 817de5658..ddc81492c 100644 --- a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/Factory.java +++ b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/Factory.java @@ -35,34 +35,35 @@ /** * Factory class for initializing the particular <b>Page Fragment</b>. - * + * * @author <a href="mailto:[email protected]">Juraj Huska</a> - * + * */ public class Factory { /** * Returns initialized Page Fragment of given type. It means that all fields annotated with <code>@FindBy</code> and * <code>@Page</code> annotations are initialized properly. - * + * * @param clazz * @param <T> the implementation of Page Fragment * @param the root element to set to the initialized Page Fragment */ public static <T> T initializePageFragment(Class<T> clazz, final WebElement root) { - if (root == null || clazz == null) { + if (clazz == null) { throw new IllegalArgumentException("Non of the parameters can be null!"); } T pageFragment = instantiatePageFragment(clazz); List<Field> fields = ReflectionHelper.getFieldsWithAnnotation(clazz, Root.class); - if (fields.size() != 1) { - throw new IllegalArgumentException("The Page Fragment has to have exactly one field annotated with Root annotation!"); + int fieldSize = fields.size(); + if (fieldSize > 1) { + throw new IllegalArgumentException("The Page Fragment" + pageFragment.getClass() + + "can not have more than one field annotated with Root annotation! Your fields with @Root annotation: " + + fields); } - - WebElement rootElement = GrapheneProxy.getProxyForTargetWithInterfaces(root, WebElement.class); - setObjectToField(fields.get(0), pageFragment, rootElement); + setObjectToField(fields.get(0), pageFragment, root); fields = ReflectionHelper.getFieldsWithAnnotation(clazz, FindBy.class); initNotPageFragmentsFields(fields, pageFragment, root); @@ -80,9 +81,8 @@ public static <T> T instantiatePageFragment(Class<T> clazz) { } /** - * If the given root is null, the driver proxy is used for finding injected - * elements, otherwise the root element is used. - * + * If the given root is null, the driver proxy is used for finding injected elements, otherwise the root element is used. + * * @param fields * @param object * @param root @@ -111,10 +111,9 @@ public static void initNotPageFragmentsFields(List<Field> fields, Object object, } /** - * Sets up the proxy element for the given By instance. If the given root is - * null, driver proxy is used for finding the web element, otherwise the root - * element is used. - * + * Sets up the proxy element for the given By instance. If the given root is null, driver proxy is used for finding the web + * element, otherwise the root element is used. + * * @param by * @param root * @return diff --git a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentsEnricher.java b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentsEnricher.java index ba27712f6..0081c1c70 100644 --- a/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentsEnricher.java +++ b/graphene-webdriver/graphene-webdriver-impl/src/main/java/org/jboss/arquillian/graphene/enricher/PageFragmentsEnricher.java @@ -23,7 +23,11 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -35,9 +39,9 @@ /** * Enricher is a class for injecting into fields initialised <code>WebElement</code> and Page Fragments instances. - * + * * @author <a href="mailto:[email protected]">Juraj Huska</a> - * + * */ public class PageFragmentsEnricher implements TestEnricher { @@ -83,25 +87,63 @@ private void initializePageObjectFields(Object testCase, List<Field> fields) { for (Field i : fields) { try { - Class declaredClass = Class.forName(i.getGenericType().toString().split(" ")[1]); - Object page = declaredClass.newInstance(); + Type type = i.getGenericType(); + Object page = null; - enrich(page); + // check whether it is type variable e.g. T + if (type instanceof TypeVariable) { - boolean accessible = i.isAccessible(); - if (!accessible) { - i.setAccessible(true); - } - i.set(testCase, page); - if (!accessible) { - i.setAccessible(false); + page = getActualType(i, testCase).newInstance(); + } else { + // no it is normal type, e.g. TestPage + Class<?> declaredClass = i.getType(); + + page = declaredClass.newInstance(); } + + enrich(page); + + Factory.setObjectToField(i, testCase, page); + } catch (Exception ex) { throw new RuntimeException("Can not initialise Page Object!"); } } } + private Class<?> getActualType(Field i, Object testCase) { + + // e.g. TestPage, HomePage + Type[] superClassActualTypeArguments = getSuperClassActualTypeArguments(testCase); + // e.g. T, E + TypeVariable<?>[] superClassTypeParameters = getSuperClassTypeParameters(testCase); + + // the type parameter has the same index as the actual type + String fieldParameterTypeName = i.getGenericType().toString(); + + int index = Arrays.asList(superClassTypeParameters).indexOf(fieldParameterTypeName); + for (index = 0; index < superClassTypeParameters.length; index++) { + String superClassTypeParameterName = superClassTypeParameters[index].getName(); + if (fieldParameterTypeName.equals(superClassTypeParameterName)) { + break; + } + } + + return (Class<?>) superClassActualTypeArguments[index]; + } + + private Type[] getSuperClassActualTypeArguments(Object testCase) { + Type[] actualTypeArguemnts = ((ParameterizedType) testCase.getClass().getGenericSuperclass()).getActualTypeArguments(); + + return actualTypeArguemnts; + } + + private TypeVariable<?>[] getSuperClassTypeParameters(Object testCase) { + TypeVariable<?>[] typeParameters = testCase.getClass().getSuperclass().getTypeParameters(); + + return typeParameters; + } + private void initPageFragmentsFields(List<Field> fields, Object object) { for (Field pageFragmentField : fields) { @@ -121,7 +163,7 @@ private void initPageFragmentsFields(List<Field> fields, Object object) { /** * It removes all fields with type <code>WebElement</code> from the given list of fields. - * + * * @param findByFields * @return */
465f1cf4f6add88ddfc6ae3ca724edf3e296b673
tapiji
Adapts license headers. Fixes Issue 75. Adds Contributors section.
p
https://github.com/tapiji/tapiji
diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/Activator.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/Activator.java index 1960c414..748769ae 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/Activator.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/Activator.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/decorators/ExcludedResource.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/decorators/ExcludedResource.java index 157ec4ee..f73022dd 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/decorators/ExcludedResource.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/decorators/ExcludedResource.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.decorators; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/AddLanguageDialoge.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/AddLanguageDialoge.java index 23e79fe9..6647543d 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/AddLanguageDialoge.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/AddLanguageDialoge.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.dialogs; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/CreatePatternDialoge.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/CreatePatternDialoge.java index df3fd5fc..64b7feda 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/CreatePatternDialoge.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/CreatePatternDialoge.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.dialogs; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/CreateResourceBundleEntryDialog.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/CreateResourceBundleEntryDialog.java index ceb18a88..75d865cb 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/CreateResourceBundleEntryDialog.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/CreateResourceBundleEntryDialog.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.dialogs; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/FragmentProjectSelectionDialog.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/FragmentProjectSelectionDialog.java index f29ac103..3b3513e0 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/FragmentProjectSelectionDialog.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/FragmentProjectSelectionDialog.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.dialogs; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/GenerateBundleAccessorDialog.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/GenerateBundleAccessorDialog.java index 5388f8a8..15b93f24 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/GenerateBundleAccessorDialog.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/GenerateBundleAccessorDialog.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.dialogs; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/QueryResourceBundleEntryDialog.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/QueryResourceBundleEntryDialog.java index 13ac24a9..3a0abf24 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/QueryResourceBundleEntryDialog.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/QueryResourceBundleEntryDialog.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.dialogs; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/RemoveLanguageDialoge.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/RemoveLanguageDialoge.java index ac950ffc..f8aab884 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/RemoveLanguageDialoge.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/RemoveLanguageDialoge.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.dialogs; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleEntrySelectionDialog.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleEntrySelectionDialog.java index 2b076285..77fd50fa 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleEntrySelectionDialog.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleEntrySelectionDialog.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.dialogs; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleSelectionDialog.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleSelectionDialog.java index 862d9d9d..809da51d 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleSelectionDialog.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/dialogs/ResourceBundleSelectionDialog.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.dialogs; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/filters/PropertiesFileFilter.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/filters/PropertiesFileFilter.java index 921d0dcd..2478c658 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/filters/PropertiesFileFilter.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/filters/PropertiesFileFilter.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.filters; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/markers/MarkerUpdater.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/markers/MarkerUpdater.java index 2d7ce104..c4920bab 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/markers/MarkerUpdater.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/markers/MarkerUpdater.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.markers; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/markers/StringLiterals.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/markers/StringLiterals.java index 5e0a1931..0588ee2e 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/markers/StringLiterals.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/markers/StringLiterals.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.markers; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/menus/InternationalizationMenu.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/menus/InternationalizationMenu.java index 7b70158e..deee5816 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/menus/InternationalizationMenu.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/menus/InternationalizationMenu.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.menus; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/BuilderPreferencePage.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/BuilderPreferencePage.java index 7c530f40..961f1ac7 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/BuilderPreferencePage.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/BuilderPreferencePage.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.prefrences; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/FilePreferencePage.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/FilePreferencePage.java index 06ca0a5f..eac76165 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/FilePreferencePage.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/FilePreferencePage.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.prefrences; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/TapiHomePreferencePage.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/TapiHomePreferencePage.java index 0cad4892..149ded96 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/TapiHomePreferencePage.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/prefrences/TapiHomePreferencePage.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.prefrences; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/quickfix/CreateResourceBundleEntry.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/quickfix/CreateResourceBundleEntry.java index b72acb63..604783c9 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/quickfix/CreateResourceBundleEntry.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/quickfix/CreateResourceBundleEntry.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.quickfix; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/MessagesView.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/MessagesView.java index 9b74a36a..0608f27e 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/MessagesView.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/MessagesView.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.views.messagesview; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/ResourceBundleEntry.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/ResourceBundleEntry.java index 82804bd0..7ac8c942 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/ResourceBundleEntry.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/ResourceBundleEntry.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.views.messagesview; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/KeyTreeItemDropTarget.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/KeyTreeItemDropTarget.java index ba85c7cb..ff911693 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/KeyTreeItemDropTarget.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/KeyTreeItemDropTarget.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.views.messagesview.dnd; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/KeyTreeItemTransfer.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/KeyTreeItemTransfer.java index f014158f..6d7a9903 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/KeyTreeItemTransfer.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/KeyTreeItemTransfer.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.views.messagesview.dnd; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/MessagesDragSource.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/MessagesDragSource.java index 26f6fd14..2ad16188 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/MessagesDragSource.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/MessagesDragSource.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.views.messagesview.dnd; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/MessagesDropTarget.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/MessagesDropTarget.java index 5c4ad5f5..3fa158ad 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/MessagesDropTarget.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/views/messagesview/dnd/MessagesDropTarget.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.views.messagesview.dnd; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/MVTextTransfer.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/MVTextTransfer.java index 5edc5a26..236b0406 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/MVTextTransfer.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/MVTextTransfer.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/PropertyKeySelectionTree.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/PropertyKeySelectionTree.java index ed29c6a5..1f05cfd8 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/PropertyKeySelectionTree.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/PropertyKeySelectionTree.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/ResourceSelector.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/ResourceSelector.java index 3fe4db34..71ea0448 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/ResourceSelector.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/ResourceSelector.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/event/ResourceSelectionEvent.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/event/ResourceSelectionEvent.java index fcf714f4..40d713a8 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/event/ResourceSelectionEvent.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/event/ResourceSelectionEvent.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.event; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/ExactMatcher.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/ExactMatcher.java index c019c468..8e5786df 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/ExactMatcher.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/ExactMatcher.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.filter; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/FilterInfo.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/FilterInfo.java index f8344096..fff5f7af 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/FilterInfo.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/FilterInfo.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.filter; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/FuzzyMatcher.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/FuzzyMatcher.java index 91518be4..79ba60e0 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/FuzzyMatcher.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/FuzzyMatcher.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.filter; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/StringMatcher.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/StringMatcher.java index 181eb687..c4cb2194 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/StringMatcher.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/filter/StringMatcher.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.filter; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/listener/IResourceSelectionListener.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/listener/IResourceSelectionListener.java index 80422753..9d44a242 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/listener/IResourceSelectionListener.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/listener/IResourceSelectionListener.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.listener; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/KeyTreeLabelProvider.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/KeyTreeLabelProvider.java index 5b99d847..ce437b45 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/KeyTreeLabelProvider.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/KeyTreeLabelProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ /* + * Copyright (C) 2003, 2004 Pascal Essiembre, Essiembre Consultant Inc. diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/LightKeyTreeLabelProvider.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/LightKeyTreeLabelProvider.java index c323b6e2..5ccb3f22 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/LightKeyTreeLabelProvider.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/LightKeyTreeLabelProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.provider; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ResKeyTreeContentProvider.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ResKeyTreeContentProvider.java index e3ed078b..724547dc 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ResKeyTreeContentProvider.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ResKeyTreeContentProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.provider; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ResKeyTreeLabelProvider.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ResKeyTreeLabelProvider.java index 332edd0e..3bbfcb9f 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ResKeyTreeLabelProvider.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ResKeyTreeLabelProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.provider; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ValueKeyTreeLabelProvider.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ValueKeyTreeLabelProvider.java index c9658063..3de94961 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ValueKeyTreeLabelProvider.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/provider/ValueKeyTreeLabelProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.provider; diff --git a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/sorter/ValuedKeyTreeItemSorter.java b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/sorter/ValuedKeyTreeItemSorter.java index 9ca3f6fd..8541037d 100644 --- a/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/sorter/ValuedKeyTreeItemSorter.java +++ b/org.eclipse.babel.tapiji.tools.core.ui/src/org/eclipse/babel/tapiji/tools/core/ui/widgets/sorter/ValuedKeyTreeItemSorter.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.ui.widgets.sorter; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/Activator.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/Activator.java index 3f15400d..7e715308 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/Activator.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/Activator.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/Logger.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/Logger.java index 27c61232..1e162d90 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/Logger.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/Logger.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/BuilderPropertyChangeListener.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/BuilderPropertyChangeListener.java index 224f0585..f2cd2b56 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/BuilderPropertyChangeListener.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/BuilderPropertyChangeListener.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/ExtensionManager.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/ExtensionManager.java index 8d7b1c5f..fa3b30a4 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/ExtensionManager.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/ExtensionManager.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/I18nBuilder.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/I18nBuilder.java index bf533ca2..d9a6b589 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/I18nBuilder.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/I18nBuilder.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/InternationalizationNature.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/InternationalizationNature.java index f583b7b1..d2979e6f 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/InternationalizationNature.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/InternationalizationNature.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/ViolationResolutionGenerator.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/ViolationResolutionGenerator.java index 413fdf68..7a7fd4a8 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/ViolationResolutionGenerator.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/ViolationResolutionGenerator.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/RBAuditor.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/RBAuditor.java index 3cb2d9e6..5cafd49d 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/RBAuditor.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/RBAuditor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder.analyzer; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/ResourceBundleDetectionVisitor.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/ResourceBundleDetectionVisitor.java index e8855981..90715d66 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/ResourceBundleDetectionVisitor.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/ResourceBundleDetectionVisitor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder.analyzer; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/ResourceFinder.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/ResourceFinder.java index 43fea867..6a6fee78 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/ResourceFinder.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/analyzer/ResourceFinder.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder.analyzer; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/quickfix/CreateResourceBundle.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/quickfix/CreateResourceBundle.java index 26e15eed..45762ea2 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/quickfix/CreateResourceBundle.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/quickfix/CreateResourceBundle.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder.quickfix; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/quickfix/IncludeResource.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/quickfix/IncludeResource.java index ec5bf19f..29648582 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/quickfix/IncludeResource.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/builder/quickfix/IncludeResource.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.builder.quickfix; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nAuditor.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nAuditor.java index 26081318..a24f6012 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nAuditor.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nAuditor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.extensions; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nRBAuditor.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nRBAuditor.java index a42841ac..d5fbb37d 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nRBAuditor.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nRBAuditor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.extensions; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nResourceAuditor.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nResourceAuditor.java index 7de52811..38427431 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nResourceAuditor.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/I18nResourceAuditor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.extensions; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/ILocation.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/ILocation.java index 44514c4d..5b44a6d6 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/ILocation.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/ILocation.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.extensions; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/IMarkerConstants.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/IMarkerConstants.java index 513daaf1..65b77225 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/IMarkerConstants.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/extensions/IMarkerConstants.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.extensions; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceBundleChangedListener.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceBundleChangedListener.java index f8879d43..31d98ac4 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceBundleChangedListener.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceBundleChangedListener.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceDescriptor.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceDescriptor.java index 95357f6e..3579810b 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceDescriptor.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceDescriptor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceExclusionListener.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceExclusionListener.java index 24d9eec6..09ac533d 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceExclusionListener.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/IResourceExclusionListener.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/ResourceDescriptor.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/ResourceDescriptor.java index eeebd481..bee918de 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/ResourceDescriptor.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/ResourceDescriptor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/SLLocation.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/SLLocation.java index ba4c83e0..84e3c57c 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/SLLocation.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/SLLocation.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/exception/NoSuchResourceAuditorException.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/exception/NoSuchResourceAuditorException.java index 46951d73..beb7436b 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/exception/NoSuchResourceAuditorException.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/exception/NoSuchResourceAuditorException.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.exception; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/exception/ResourceBundleException.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/exception/ResourceBundleException.java index dac5453a..51eda8e6 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/exception/ResourceBundleException.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/exception/ResourceBundleException.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.exception; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/RBChangeListner.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/RBChangeListner.java index 4b0f0183..4dca02df 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/RBChangeListner.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/RBChangeListner.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.manager; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleChangedEvent.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleChangedEvent.java index 45e49081..4e4079b7 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleChangedEvent.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleChangedEvent.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.manager; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleDetector.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleDetector.java index 335ce079..7bae005b 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleDetector.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleDetector.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.manager; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleManager.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleManager.java index 8ec9f452..b41328e0 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleManager.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceBundleManager.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.manager; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceExclusionEvent.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceExclusionEvent.java index 8b3e7020..d29de40c 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceExclusionEvent.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/manager/ResourceExclusionEvent.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.manager; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/CheckItem.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/CheckItem.java index 0b340de1..29e19226 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/CheckItem.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/CheckItem.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.preferences; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/TapiJIPreferenceInitializer.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/TapiJIPreferenceInitializer.java index 6056a468..5ca700d8 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/TapiJIPreferenceInitializer.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/TapiJIPreferenceInitializer.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.preferences; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/TapiJIPreferences.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/TapiJIPreferences.java index 661eb86d..127924e0 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/TapiJIPreferences.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/preferences/TapiJIPreferences.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.preferences; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/view/MessagesViewState.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/view/MessagesViewState.java index 7b04b59c..22f98efa 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/view/MessagesViewState.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/view/MessagesViewState.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.view; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/view/SortInfo.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/view/SortInfo.java index 0c55cf07..c907c676 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/view/SortInfo.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/model/view/SortInfo.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.model.view; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/EditorUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/EditorUtils.java index dce8cebb..38cd8def 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/EditorUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/EditorUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FileUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FileUtils.java index 93963c2a..db5552bc 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FileUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FileUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FontUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FontUtils.java index 487bf8fe..c655986d 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FontUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FontUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FragmentProjectUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FragmentProjectUtils.java index 00daacf8..0f6f5c33 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FragmentProjectUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/FragmentProjectUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/ImageUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/ImageUtils.java index 91aa4402..952f93f9 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/ImageUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/ImageUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/LanguageUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/LanguageUtils.java index 7628e8ad..247aab8a 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/LanguageUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/LanguageUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/LocaleUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/LocaleUtils.java index 71d22de6..76a90ea0 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/LocaleUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/LocaleUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/OverlayIcon.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/OverlayIcon.java index dbdc1957..bcd1cc8f 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/OverlayIcon.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/OverlayIcon.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/PDEUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/PDEUtils.java index 378a2b0f..c268c8c4 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/PDEUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/PDEUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ /* * Copyright (C) 2007 Uwe Voigt diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/RBFileUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/RBFileUtils.java index ec3f5d6d..c496ed82 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/RBFileUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/RBFileUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/ResourceUtils.java b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/ResourceUtils.java index 2f8f8a2c..39334de6 100644 --- a/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/ResourceUtils.java +++ b/org.eclipse.babel.tapiji.tools.core/src/org/eclipse/babel/tapiji/tools/core/util/ResourceUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.core.util; diff --git a/org.eclipse.babel.tapiji.tools.java/src/org/eclipse/babel/tapiji/tools/java/visitor/MethodParameterDescriptor.java b/org.eclipse.babel.tapiji.tools.java/src/org/eclipse/babel/tapiji/tools/java/visitor/MethodParameterDescriptor.java index d342601b..9b8639ad 100644 --- a/org.eclipse.babel.tapiji.tools.java/src/org/eclipse/babel/tapiji/tools/java/visitor/MethodParameterDescriptor.java +++ b/org.eclipse.babel.tapiji.tools.java/src/org/eclipse/babel/tapiji/tools/java/visitor/MethodParameterDescriptor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.java.visitor; diff --git a/org.eclipse.babel.tapiji.tools.java/src/org/eclipse/babel/tapiji/tools/java/visitor/ResourceAuditVisitor.java b/org.eclipse.babel.tapiji.tools.java/src/org/eclipse/babel/tapiji/tools/java/visitor/ResourceAuditVisitor.java index 604cab2e..5fd3a699 100644 --- a/org.eclipse.babel.tapiji.tools.java/src/org/eclipse/babel/tapiji/tools/java/visitor/ResourceAuditVisitor.java +++ b/org.eclipse.babel.tapiji.tools.java/src/org/eclipse/babel/tapiji/tools/java/visitor/ResourceAuditVisitor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.java.visitor; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ImageUtils.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ImageUtils.java index e7833c63..6da4458a 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ImageUtils.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ImageUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/RBManagerActivator.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/RBManagerActivator.java index e4ac257f..29ff9963 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/RBManagerActivator.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/RBManagerActivator.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/RBLocation.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/RBLocation.java index 2c016bca..2df648b2 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/RBLocation.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/RBLocation.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.auditor; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/ResourceBundleAuditor.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/ResourceBundleAuditor.java index 5328590c..ac0938f7 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/ResourceBundleAuditor.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/ResourceBundleAuditor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.auditor; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/quickfix/MissingLanguageResolution.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/quickfix/MissingLanguageResolution.java index b8cbe530..c0797226 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/quickfix/MissingLanguageResolution.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/auditor/quickfix/MissingLanguageResolution.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.auditor.quickfix; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualContainer.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualContainer.java index 3ea8a638..67d4eece 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualContainer.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualContainer.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.model; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualContentManager.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualContentManager.java index 52f51e51..c600633f 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualContentManager.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualContentManager.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.model; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualProject.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualProject.java index c04a2e3c..ea1772a6 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualProject.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualProject.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.model; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualResourceBundle.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualResourceBundle.java index 76c1a389..6b969fc8 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualResourceBundle.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/model/VirtualResourceBundle.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.model; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/hover/Hover.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/hover/Hover.java index 1ed2e792..4adf2c97 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/hover/Hover.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/hover/Hover.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.ui.hover; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/hover/HoverInformant.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/hover/HoverInformant.java index eed0abf7..d4b5e5f5 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/hover/HoverInformant.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/hover/HoverInformant.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.ui.hover; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/view/toolbarItems/ExpandAllActionDelegate.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/view/toolbarItems/ExpandAllActionDelegate.java index 17c0eba3..5db0bf6f 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/view/toolbarItems/ExpandAllActionDelegate.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/view/toolbarItems/ExpandAllActionDelegate.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.ui.view.toolbarItems; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/view/toolbarItems/ToggleFilterActionDelegate.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/view/toolbarItems/ToggleFilterActionDelegate.java index 53352c24..6f1af0ec 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/view/toolbarItems/ToggleFilterActionDelegate.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/ui/view/toolbarItems/ToggleFilterActionDelegate.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.ui.view.toolbarItems; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/LinkHelper.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/LinkHelper.java index a88d6f64..66d5fbbe 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/LinkHelper.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/LinkHelper.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/ResourceBundleContentProvider.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/ResourceBundleContentProvider.java index 21b7641c..16f7005e 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/ResourceBundleContentProvider.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/ResourceBundleContentProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/ResourceBundleLabelProvider.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/ResourceBundleLabelProvider.java index b1c1fe32..38c311a5 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/ResourceBundleLabelProvider.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/ResourceBundleLabelProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/ExpandAction.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/ExpandAction.java index 4e939200..76f2fcae 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/ExpandAction.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/ExpandAction.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer.actions; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/GeneralActionProvider.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/GeneralActionProvider.java index 1fb7a65f..4b21797d 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/GeneralActionProvider.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/GeneralActionProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer.actions; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/OpenVRBAction.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/OpenVRBAction.java index 6fbe5dc8..9645bcbc 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/OpenVRBAction.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/OpenVRBAction.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer.actions; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/VirtualRBActionProvider.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/VirtualRBActionProvider.java index 71c22668..3d435aed 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/VirtualRBActionProvider.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/VirtualRBActionProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer.actions; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/hoverinformants/I18NProjectInformant.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/hoverinformants/I18NProjectInformant.java index 086dd235..ecd02a58 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/hoverinformants/I18NProjectInformant.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/hoverinformants/I18NProjectInformant.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer.actions.hoverinformants; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/hoverinformants/RBMarkerInformant.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/hoverinformants/RBMarkerInformant.java index ed1164c0..40e3b12b 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/hoverinformants/RBMarkerInformant.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/actions/hoverinformants/RBMarkerInformant.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer.actions.hoverinformants; diff --git a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/filters/ProblematicResourceBundleFilter.java b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/filters/ProblematicResourceBundleFilter.java index bb0d56a8..02fa1142 100644 --- a/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/filters/ProblematicResourceBundleFilter.java +++ b/org.eclipse.babel.tapiji.tools.rbmanager/src/org/eclipse/babel/tapiji/tools/rbmanager/viewer/filters/ProblematicResourceBundleFilter.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.tools.rbmanager.viewer.filters; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IAbstractKeyTreeModel.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IAbstractKeyTreeModel.java index 0248bdd8..98b25018 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IAbstractKeyTreeModel.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IAbstractKeyTreeModel.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeContributor.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeContributor.java index 88f2d84b..8d59daf5 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeContributor.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeContributor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeNode.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeNode.java index bc1509f8..0f86d946 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeNode.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeNode.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeVisitor.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeVisitor.java index e7f294e4..7e136194 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeVisitor.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IKeyTreeVisitor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessage.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessage.java index 54bd0359..9c62be4b 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessage.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessage.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesBundle.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesBundle.java index 4fdbc9f8..34853fb4 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesBundle.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesBundle.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesBundleGroup.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesBundleGroup.java index 78aefc04..0dbdc00a 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesBundleGroup.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesBundleGroup.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesEditor.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesEditor.java index c6133588..87729d1f 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesEditor.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesEditor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesResource.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesResource.java index b82b1214..db071eb3 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesResource.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesResource.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesResourceChangeListener.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesResourceChangeListener.java index dba216bb..07600e20 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesResourceChangeListener.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IMessagesResourceChangeListener.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IValuedKeyTreeNode.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IValuedKeyTreeNode.java index 6673e1fb..d5c84662 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IValuedKeyTreeNode.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/IValuedKeyTreeNode.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.babel.bundle; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/TreeType.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/TreeType.java index 6b383220..4c0bb023 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/TreeType.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/babel/bundle/TreeType.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ /** * diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/model/analyze/ILevenshteinDistanceAnalyzer.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/model/analyze/ILevenshteinDistanceAnalyzer.java index e966386c..95039d4a 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/model/analyze/ILevenshteinDistanceAnalyzer.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/model/analyze/ILevenshteinDistanceAnalyzer.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.model.analyze; diff --git a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/ui/wizards/IResourceBundleWizard.java b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/ui/wizards/IResourceBundleWizard.java index 8620545a..2d855b22 100644 --- a/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/ui/wizards/IResourceBundleWizard.java +++ b/org.eclipse.babel.tapiji.translator.rbe/src/org/eclipse/babel/tapiji/translator/rbe/ui/wizards/IResourceBundleWizard.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipse.babel.tapiji.translator.rbe.ui.wizards; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/auditor/JSFResourceAuditor.java b/org.eclipselabs.tapiji.tools.jsf/src/auditor/JSFResourceAuditor.java index d70a0da9..700a2c05 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/auditor/JSFResourceAuditor.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/auditor/JSFResourceAuditor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package auditor; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/auditor/JSFResourceBundleDetector.java b/org.eclipselabs.tapiji.tools.jsf/src/auditor/JSFResourceBundleDetector.java index 89533285..e63caa94 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/auditor/JSFResourceBundleDetector.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/auditor/JSFResourceBundleDetector.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package auditor; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/auditor/model/SLLocation.java b/org.eclipselabs.tapiji.tools.jsf/src/auditor/model/SLLocation.java index 63918ce1..2e07a824 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/auditor/model/SLLocation.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/auditor/model/SLLocation.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package auditor.model; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ExportToResourceBundleResolution.java b/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ExportToResourceBundleResolution.java index 58f869d6..6e8fe8d8 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ExportToResourceBundleResolution.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ExportToResourceBundleResolution.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package quickfix; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/quickfix/JSFViolationResolutionGenerator.java b/org.eclipselabs.tapiji.tools.jsf/src/quickfix/JSFViolationResolutionGenerator.java index 95b21cfa..fd912c66 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/quickfix/JSFViolationResolutionGenerator.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/quickfix/JSFViolationResolutionGenerator.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package quickfix; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ReplaceResourceBundleDefReference.java b/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ReplaceResourceBundleDefReference.java index 8d34a36c..b1a86373 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ReplaceResourceBundleDefReference.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ReplaceResourceBundleDefReference.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package quickfix; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ReplaceResourceBundleReference.java b/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ReplaceResourceBundleReference.java index cb15b9f9..f890d1e5 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ReplaceResourceBundleReference.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/quickfix/ReplaceResourceBundleReference.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package quickfix; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/ui/JSFELMessageHover.java b/org.eclipselabs.tapiji.tools.jsf/src/ui/JSFELMessageHover.java index 9da1e63b..f539768d 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/ui/JSFELMessageHover.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/ui/JSFELMessageHover.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package ui; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/BundleNameProposal.java b/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/BundleNameProposal.java index 6406701d..68bcbed5 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/BundleNameProposal.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/BundleNameProposal.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package ui.autocompletion; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/MessageCompletionProposal.java b/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/MessageCompletionProposal.java index 2ed64653..3753f9e4 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/MessageCompletionProposal.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/MessageCompletionProposal.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package ui.autocompletion; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/NewResourceBundleEntryProposal.java b/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/NewResourceBundleEntryProposal.java index f2a76cd8..278f3669 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/NewResourceBundleEntryProposal.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/NewResourceBundleEntryProposal.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package ui.autocompletion; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/jsf/MessageCompletionProposal.java b/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/jsf/MessageCompletionProposal.java index 815f6c86..02ab4f34 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/jsf/MessageCompletionProposal.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/ui/autocompletion/jsf/MessageCompletionProposal.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package ui.autocompletion.jsf; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/util/ELUtils.java b/org.eclipselabs.tapiji.tools.jsf/src/util/ELUtils.java index 4e518a6f..695eb4bc 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/util/ELUtils.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/util/ELUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package util; diff --git a/org.eclipselabs.tapiji.tools.jsf/src/validator/JSFInternationalizationValidator.java b/org.eclipselabs.tapiji.tools.jsf/src/validator/JSFInternationalizationValidator.java index afd6f9dd..e6b5e9bb 100644 --- a/org.eclipselabs.tapiji.tools.jsf/src/validator/JSFInternationalizationValidator.java +++ b/org.eclipselabs.tapiji.tools.jsf/src/validator/JSFInternationalizationValidator.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package validator; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Activator.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Activator.java index 5b5f1bff..15c2d2a5 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Activator.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Activator.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Application.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Application.java index e641189c..4a474902 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Application.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Application.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationActionBarAdvisor.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationActionBarAdvisor.java index 27ebb38c..e9649ad1 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationActionBarAdvisor.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationActionBarAdvisor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationWorkbenchAdvisor.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationWorkbenchAdvisor.java index 655f465b..4d0ea4ae 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationWorkbenchAdvisor.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationWorkbenchAdvisor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationWorkbenchWindowAdvisor.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationWorkbenchWindowAdvisor.java index c06b2f52..c56933e4 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationWorkbenchWindowAdvisor.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/ApplicationWorkbenchWindowAdvisor.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Perspective.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Perspective.java index 986a37ce..1eebca8b 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Perspective.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/Perspective.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/FileOpenAction.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/FileOpenAction.java index c661bf42..66fac9ba 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/FileOpenAction.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/FileOpenAction.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.actions; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/NewGlossaryAction.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/NewGlossaryAction.java index 66b123d8..1d7339b1 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/NewGlossaryAction.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/NewGlossaryAction.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.actions; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/OpenGlossaryAction.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/OpenGlossaryAction.java index 40a8c894..04ee0f18 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/OpenGlossaryAction.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/actions/OpenGlossaryAction.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.actions; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/GlossaryManager.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/GlossaryManager.java index 4e687773..5d04f308 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/GlossaryManager.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/GlossaryManager.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.core; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/ILoadGlossaryListener.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/ILoadGlossaryListener.java index 69095e11..591edac6 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/ILoadGlossaryListener.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/ILoadGlossaryListener.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.core; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/LoadGlossaryEvent.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/LoadGlossaryEvent.java index 6b344ae0..815f31d1 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/LoadGlossaryEvent.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/core/LoadGlossaryEvent.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.core; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Glossary.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Glossary.java index 3aad69e2..0aa1aad6 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Glossary.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Glossary.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.model; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Info.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Info.java index 4efbdce6..fbfff0c5 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Info.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Info.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.model; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Term.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Term.java index 3cbdc581..16373066 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Term.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Term.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.model; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Translation.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Translation.java index 493f01ab..df44500e 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Translation.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/model/Translation.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.model; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/tests/JaxBTest.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/tests/JaxBTest.java index 6985a578..62386f6a 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/tests/JaxBTest.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/tests/JaxBTest.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.tests; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/utils/FileUtils.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/utils/FileUtils.java index e12a577e..38f488dc 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/utils/FileUtils.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/utils/FileUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.utils; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/utils/FontUtils.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/utils/FontUtils.java index cfddb70c..9917728a 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/utils/FontUtils.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/utils/FontUtils.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.utils; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/GlossaryView.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/GlossaryView.java index 47549301..ab0eb2f2 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/GlossaryView.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/GlossaryView.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/dialog/LocaleContentProvider.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/dialog/LocaleContentProvider.java index fda93b86..353d9415 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/dialog/LocaleContentProvider.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/dialog/LocaleContentProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.dialog; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/dialog/LocaleLabelProvider.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/dialog/LocaleLabelProvider.java index 60002ded..c4f32d11 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/dialog/LocaleLabelProvider.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/dialog/LocaleLabelProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.dialog; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/menus/GlossaryEntryMenuContribution.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/menus/GlossaryEntryMenuContribution.java index 9d7d2551..344947eb 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/menus/GlossaryEntryMenuContribution.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/menus/GlossaryEntryMenuContribution.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.menus; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/GlossaryWidget.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/GlossaryWidget.java index bff167cf..2180a60e 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/GlossaryWidget.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/GlossaryWidget.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/GlossaryDragSource.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/GlossaryDragSource.java index 6daea2d2..2215ea67 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/GlossaryDragSource.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/GlossaryDragSource.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.dnd; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/GlossaryDropTarget.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/GlossaryDropTarget.java index e23a3b6b..15758404 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/GlossaryDropTarget.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/GlossaryDropTarget.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.dnd; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/TermTransfer.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/TermTransfer.java index ce50aaa7..1c078ceb 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/TermTransfer.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/dnd/TermTransfer.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.dnd; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/ExactMatcher.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/ExactMatcher.java index 3227159b..0c2cfb3d 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/ExactMatcher.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/ExactMatcher.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.filter; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/FilterInfo.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/FilterInfo.java index 5eb32ba5..281f4244 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/FilterInfo.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/FilterInfo.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.filter; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/FuzzyMatcher.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/FuzzyMatcher.java index 79578016..1a9eba5e 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/FuzzyMatcher.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/FuzzyMatcher.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.filter; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/SelectiveMatcher.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/SelectiveMatcher.java index 4e4c9207..daf8ccf8 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/SelectiveMatcher.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/SelectiveMatcher.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.filter; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/StringMatcher.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/StringMatcher.java index 939f074f..d0433354 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/StringMatcher.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/filter/StringMatcher.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.filter; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/model/GlossaryViewState.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/model/GlossaryViewState.java index 1c3e965c..bbc057f8 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/model/GlossaryViewState.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/model/GlossaryViewState.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.model; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/provider/GlossaryContentProvider.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/provider/GlossaryContentProvider.java index 4ffa91d6..8ba0e499 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/provider/GlossaryContentProvider.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/provider/GlossaryContentProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.provider; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/provider/GlossaryLabelProvider.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/provider/GlossaryLabelProvider.java index aada0686..c021994b 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/provider/GlossaryLabelProvider.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/provider/GlossaryLabelProvider.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.provider; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/sorter/GlossaryEntrySorter.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/sorter/GlossaryEntrySorter.java index fb4390a4..c92e7d9a 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/sorter/GlossaryEntrySorter.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/sorter/GlossaryEntrySorter.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.sorter; diff --git a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/sorter/SortInfo.java b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/sorter/SortInfo.java index ec08283b..125018c5 100644 --- a/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/sorter/SortInfo.java +++ b/org.eclipselabs.tapiji.translator/src/org/eclipselabs/tapiji/translator/views/widgets/sorter/SortInfo.java @@ -4,6 +4,9 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Reiterer - initial API and implementation ******************************************************************************/ package org.eclipselabs.tapiji.translator.views.widgets.sorter;
737a1463232535f487850f80fe0fb49b4978f77e
Valadoc
libvaladoc: add helpers for valadoc.org
a
https://github.com/GNOME/vala/
diff --git a/src/libvaladoc/api/node.vala b/src/libvaladoc/api/node.vala index 48cb6009cd..ab440ba148 100755 --- a/src/libvaladoc/api/node.vala +++ b/src/libvaladoc/api/node.vala @@ -47,7 +47,74 @@ public enum Valadoc.Api.NodeType { SIGNAL, STATIC_METHOD, STRUCT, - TYPE_PARAMETER + TYPE_PARAMETER; + + public string to_string () { + switch (this) { + case CLASS: + return "CLASS"; + + case CONSTANT: + return "CONSTANT"; + + case CREATION_METHOD: + return "CREATION_METHOD"; + + case DELEGATE: + return "DELEGATE"; + + case ENUM: + return "ENUM"; + + case ENUM_VALUE: + return "ENUM_VALUE"; + + case ERROR_CODE: + return "ERROR_CODE"; + + case ERROR_DOMAIN: + return "ERROR_DOMAIN"; + + case FIELD: + return "FIELD"; + + case FORMAL_PARAMETER: + return "FORMAL_PARAMETER"; + + case INTERFACE: + return "INTERFACE"; + + case METHOD: + return "METHOD"; + + case NAMESPACE: + return "NAMESPACE"; + + case PACKAGE: + return "PACKAGE"; + + case PROPERTY: + return "PROPERTY"; + + case PROPERTY_ACCESSOR: + return "PROPERTY_ACCESSOR"; + + case SIGNAL: + return "SIGNAL"; + + case STATIC_METHOD: + return "STATIC_METHOD"; + + case STRUCT: + return "STRUCT"; + + case TYPE_PARAMETER: + return "TYPE_PARAMETER"; + + default: + assert_not_reached (); + } + } } /** diff --git a/src/libvaladoc/charts/chart.vala b/src/libvaladoc/charts/chart.vala index caedfd308c..f4b99088c3 100755 --- a/src/libvaladoc/charts/chart.vala +++ b/src/libvaladoc/charts/chart.vala @@ -50,6 +50,17 @@ public class Valadoc.Charts.Chart : Api.Visitor { context.render (graph, file_type, file); } + public uint8[] write_buffer (string file_type) { + if (context == null) { + context = factory.create_context (graph); + } + + uint8[] data; + + context.render_data (graph, file_type, out data); + return data; + } + ~Chart () { if (context != null) { context.free_layout (graph); diff --git a/src/libvaladoc/html/htmlmarkupwriter.vala b/src/libvaladoc/html/htmlmarkupwriter.vala index 13e6cd0ebd..435d833a19 100755 --- a/src/libvaladoc/html/htmlmarkupwriter.vala +++ b/src/libvaladoc/html/htmlmarkupwriter.vala @@ -24,19 +24,26 @@ using GLib; using Valadoc.Content; public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter { - private unowned FileStream stream; public MarkupWriter (FileStream stream, bool xml_declaration = true) { // avoid broken implicit copy unowned FileStream _stream = stream; base ((str) => { _stream.printf (str); }, xml_declaration); - this.stream = stream; + } + + public MarkupWriter.builder (StringBuilder builder, bool xml_declaration = true) { + // avoid broken implicit copy + unowned StringBuilder _builder = builder; + + base ((str) => { _builder.append (str); }, xml_declaration); } public MarkupWriter add_usemap (Charts.Chart chart) { - stream.putc ('\n'); - chart.write (stream, "cmapx"); + string buf = (string) chart.write_buffer ("cmapx"); + raw_text ("\n"); + raw_text (buf); + return this; }
baa11dd552580abb28431ba890e7c3a90363da5d
tapiji
Consistently remove remaining JDT dependencies from the RCP translator's product definition
a
https://github.com/tapiji/tapiji
diff --git a/org.eclipselabs.tapiji.translator.swt.product/org.eclipselabs.tapiji.translator.swt.product.product b/org.eclipselabs.tapiji.translator.swt.product/org.eclipselabs.tapiji.translator.swt.product.product index 6b53d02a..c23d3e83 100644 --- a/org.eclipselabs.tapiji.translator.swt.product/org.eclipselabs.tapiji.translator.swt.product.product +++ b/org.eclipselabs.tapiji.translator.swt.product/org.eclipselabs.tapiji.translator.swt.product.product @@ -21,6 +21,7 @@ by Stefan Strobl &amp; Martin Reiterer <windowImages i16="/org.eclipselabs.tapiji.translator/icons/TapiJI_16.png" i32="/org.eclipselabs.tapiji.translator/icons/TapiJI_32.png" i48="/org.eclipselabs.tapiji.translator/icons/TapiJI_48.png" i64="/org.eclipselabs.tapiji.translator/icons/TapiJI_64.png" i128="/org.eclipselabs.tapiji.translator/icons/TapiJI_128.png"/> + <launcher> <solaris/> <win useIco="false"> @@ -28,6 +29,7 @@ by Stefan Strobl &amp; Martin Reiterer </win> </launcher> + <vm> </vm> @@ -237,6 +239,7 @@ litigation. <plugin id="com.ibm.icu"/> <plugin id="org.eclipse.ant.core"/> <plugin id="org.eclipse.babel.core"/> + <plugin id="org.eclipse.babel.core.pdeutils" fragment="true"/> <plugin id="org.eclipse.babel.editor"/> <plugin id="org.eclipse.babel.editor.nls" fragment="true"/> <plugin id="org.eclipse.babel.editor.swt" fragment="true"/> @@ -292,7 +295,10 @@ litigation. <plugin id="org.eclipse.ltk.ui.refactoring"/> <plugin id="org.eclipse.osgi"/> <plugin id="org.eclipse.osgi.services"/> + <plugin id="org.eclipse.pde.build"/> + <plugin id="org.eclipse.pde.core"/> <plugin id="org.eclipse.swt"/> + <plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true"/> <plugin id="org.eclipse.team.core"/> <plugin id="org.eclipse.team.ui"/> <plugin id="org.eclipse.text"/> @@ -306,6 +312,7 @@ litigation. <plugin id="org.eclipse.ui.workbench.texteditor"/> <plugin id="org.eclipse.update.configurator"/> <plugin id="org.eclipselabs.tapiji.translator"/> + <plugin id="org.eclipselabs.tapiji.translator.swt" fragment="true"/> <plugin id="org.eclipselabs.tapiji.translator.swt.compat"/> <plugin id="org.hamcrest.core"/> <plugin id="org.junit"/>
8e0929833e4ea0fdab34a0431dcbe109a9f5da98
fenix-framework$fenix-framework
Rename FenixCache to SharedIdentityMap * Created the interface IdentityMap, which the SharedIdentityMap now implements. The purpose of this change is to enable alternative mechanisms of identity mapping, such as per-session, instead of the current default global mapper. * The previous functionality of the FenixCache remains the same (now under a new name).
p
https://github.com/fenix-framework/fenix-framework
diff --git a/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/backend/mem/CoreDomainObject.java b/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/backend/mem/CoreDomainObject.java index a752b75ff..a6cd438c6 100644 --- a/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/backend/mem/CoreDomainObject.java +++ b/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/backend/mem/CoreDomainObject.java @@ -9,7 +9,7 @@ import pt.ist.fenixframework.DomainObject; import pt.ist.fenixframework.FenixFramework; import pt.ist.fenixframework.core.AbstractDomainObjectAdapter; -import pt.ist.fenixframework.core.FenixCache; +import pt.ist.fenixframework.core.SharedIdentityMap; public class CoreDomainObject extends AbstractDomainObjectAdapter { private static final Logger logger = Logger.getLogger(CoreDomainObject.class); @@ -28,7 +28,7 @@ protected void ensureOid() { // find successive ids until one is available while (true) { this.oid = DomainClassInfo.getNextOidFor(this.getClass()); - Object cached = FenixCache.getCache().cache(this); + Object cached = SharedIdentityMap.getCache().cache(this); if (cached == this) { // break the loop once we got this instance cached return; @@ -49,7 +49,7 @@ public final String getExternalId() { } public static <T extends DomainObject> T fromOid(long oid) { - return (T) FenixCache.getCache().lookup(oid); + return (T) SharedIdentityMap.getCache().lookup(oid); } } diff --git a/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/core/IdentityMap.java b/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/core/IdentityMap.java new file mode 100644 index 000000000..a20806da3 --- /dev/null +++ b/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/core/IdentityMap.java @@ -0,0 +1,7 @@ +package pt.ist.fenixframework.core; + +public interface IdentityMap { + + public AbstractDomainObject cache(AbstractDomainObject obj); + public AbstractDomainObject lookup(Object key); +} diff --git a/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/core/FenixCache.java b/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/core/SharedIdentityMap.java similarity index 92% rename from new-fenix-framework-core/src/main/java/pt/ist/fenixframework/core/FenixCache.java rename to new-fenix-framework-core/src/main/java/pt/ist/fenixframework/core/SharedIdentityMap.java index f719644b9..56064954f 100644 --- a/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/core/FenixCache.java +++ b/new-fenix-framework-core/src/main/java/pt/ist/fenixframework/core/SharedIdentityMap.java @@ -7,21 +7,22 @@ import pt.ist.fenixframework.core.AbstractDomainObject; -public class FenixCache { - private final static FenixCache instance = new FenixCache(); +public class SharedIdentityMap implements IdentityMap { + private final static SharedIdentityMap instance = new SharedIdentityMap(); private static final ReferenceQueue<AbstractDomainObject> refQueue = new ReferenceQueue<AbstractDomainObject>(); private ConcurrentHashMap<Object,CacheEntry> cache; - public FenixCache() { + public SharedIdentityMap() { this.cache = new ConcurrentHashMap<Object,CacheEntry>(); } - public static FenixCache getCache() { + public static SharedIdentityMap getCache() { return instance; } + @Override public AbstractDomainObject cache(AbstractDomainObject obj) { processQueue(); Object key = obj.getOid(); @@ -47,6 +48,7 @@ private AbstractDomainObject cacheNewEntry(CacheEntry newEntry, AbstractDomainOb } } + @Override public AbstractDomainObject lookup(Object key) { processQueue(); CacheEntry entry = this.cache.get(key);
69a34741cea3bbca8a92f77e00ed6955c52b428a
hunterhacker$jdom
Integrated a major path from Rolf Lear (rlearATalgorithmics.com). Below is his 6/4/2003 email. I tagged the code "before_rolf" so if we decide to back this out it's easy. -jh- I have had a look at the Child/Parent thing. Personally, I don't think the Idea has been taken far enough, so I played around with the concept, and "normalised" some of the redundancies. Firstly, I converted the Child interface into an Abstract class that deals with ALL Parent/child relationships for the Child role, including detaching, cloning, set/getParent (and holds the parent instance field). I also implemented getDocument at the Child Class level (all children have the same mechanism for getting the Document). Next, I added the method "getDocument" to the Parent Interface... and parent can getDocument, including the Document class which has "return this;" in the getDocument(). Finally, I changed the ContentList class substantially. elementData is now called childData, and is of type Child[] instead of Object[]. The ContentList owner is now of type Parent instead of Object. I have added a method canContain to the Parent interface, and thus the actual Parent object determines what content is allowed in the contentlist, so instead of add(int,Text), add(int,Element), add(int,CDATA), add(int,ProcessingInstruction), etc, there is just add(int, Child). In doing all of the above, I have cut large amounts of redundant/duplicated code, simplified the relationships, and thrown away "special cases". The only downside I can see in terms of "functionality" is that some of the exceptions are thrown with less specialised messages... Please have a look, and comment on the concept. Note, that this is only possible by converting Child to an abstract class instead of an interface. Rolf
p
https://github.com/hunterhacker/jdom
diff --git a/core/src/java/org/jdom/Child.java b/core/src/java/org/jdom/Child.java index ee756a0b6..752619f99 100644 --- a/core/src/java/org/jdom/Child.java +++ b/core/src/java/org/jdom/Child.java @@ -1,6 +1,6 @@ /*-- - $Id: Child.java,v 1.3 2003/06/04 17:40:52 jhunter Exp $ + $Id: Child.java,v 1.4 2004/02/06 03:39:02 jhunter Exp $ Copyright (C) 2000 Brett McLaughlin & Jason Hunter. All rights reserved. @@ -72,41 +72,68 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * * @author Bradley S. Huffman * @author Jason Hunter - * @version $Revision: 1.3 $, $Date: 2003/06/04 17:40:52 $ + * @version $Revision: 1.4 $, $Date: 2004/02/06 03:39:02 $ */ -public interface Child extends Cloneable, Serializable { - +public abstract class Child implements Cloneable, Serializable { + + protected Parent parent = null; + + protected Child() {} + /** * Detaches this child from its parent or does nothing if the child * has no parent. * * @return this child detached */ - Child detach(); + public Child detach() { + if (parent != null) { + parent.removeContent(this); + } + return this; + } + + /** + * Return this child's parent, or null if this child is currently + * not attached. The parent can be either an {@link Element} + * or a {@link Document}. + * + * @return this child's parent or null if none + */ + public Parent getParent() { + return parent; + } /** - * Return this child's owning document or null if the branch containing - * this child is currently not attached to a document. + * Sets the parent of this Child. The caller is responsible for removing + * any pre-existing parentage. * - * @return this child's owning document or null if none + * @param parent new parent element + * @return the target element */ - Document getDocument(); + protected Child setParent(Parent parent) { + this.parent = parent; + return this; + } /** - * Return this child's parent, or null if this child is currently - * not attached. The parent can be either an {@link Element} - * or a {@link Document}. + * Return this child's owning document or null if the branch containing + * this child is currently not attached to a document. * - * @return this child's parent or null if none + * @return this child's owning document or null if none */ - Parent getParent(); + public Document getDocument() { + if (parent == null) return null; + return parent.getDocument(); + } + /** * Returns the XPath 1.0 string value of this child. * * @return xpath string value of this child. */ - String getValue(); + public abstract String getValue(); /** * Returns a deep, unattached copy of this child and its descendants @@ -114,5 +141,15 @@ public interface Child extends Cloneable, Serializable { * * @return a detached deep copy of this child and descendants */ - Object clone(); + public Object clone() { + try { + Child c = (Child)super.clone(); + c.parent = null; + return c; + } catch (CloneNotSupportedException e) { + //Can not happen .... + //e.printStackTrace(); + return null; + } + } } diff --git a/core/src/java/org/jdom/Comment.java b/core/src/java/org/jdom/Comment.java index a2bbe6b66..2287c48f2 100644 --- a/core/src/java/org/jdom/Comment.java +++ b/core/src/java/org/jdom/Comment.java @@ -1,6 +1,6 @@ /*-- - $Id: Comment.java,v 1.28 2003/05/20 21:53:59 jhunter Exp $ + $Id: Comment.java,v 1.29 2004/02/06 03:39:02 jhunter Exp $ Copyright (C) 2000 Jason Hunter & Brett McLaughlin. All rights reserved. @@ -60,21 +60,18 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * An XML comment. Methods allow the user to get and set the text of the * comment. * - * @version $Revision: 1.28 $, $Date: 2003/05/20 21:53:59 $ + * @version $Revision: 1.29 $, $Date: 2004/02/06 03:39:02 $ * @author Brett McLaughlin * @author Jason Hunter */ -public class Comment implements Child { +public class Comment extends Child { private static final String CVS_ID = - "@(#) $RCSfile: Comment.java,v $ $Revision: 1.28 $ $Date: 2003/05/20 21:53:59 $ $Name: $"; + "@(#) $RCSfile: Comment.java,v $ $Revision: 1.29 $ $Date: 2004/02/06 03:39:02 $ $Name: $"; /** Text of the <code>Comment</code> */ protected String text; - /** Parent element, document, or null if none */ - protected Parent parent; - /** * Default, no-args constructor for implementations to use if needed. */ @@ -89,18 +86,6 @@ public Comment(String text) { setText(text); } - /** - * This will return the parent of this <code>Comment</code>. - * If there is no parent, then this returns <code>null</code>. - * - * @return parent of this <code>Comment</code> - */ - public Parent getParent() { - if (parent instanceof Element) { - return (Element) parent; - } - return null; - } /** * Returns the XPath 1.0 string value of this element, which is the @@ -112,48 +97,6 @@ public String getValue() { return text; } - /** - * This will set the parent of this <code>Comment</code>. - * - * @param parent <code>Element</code> to be new parent. - * @return this <code>Comment</code> modified. - */ - protected Comment setParent(Parent parent) { - this.parent = parent; - return this; - } - - /** - * This detaches the <code>Comment</code> from its parent, or does - * nothing if the <code>Comment</code> has no parent. - * - * @return <code>Comment</code> - this - * <code>Comment</code> modified. - */ - public Child detach() { - if (parent != null) { - parent.removeContent(this); - } - return this; - } - - /** - * This retrieves the owning <code>{@link Document}</code> for - * this Comment, or null if not a currently a member of a - * <code>{@link Document}</code>. - * - * @return <code>Document</code> owning this Element, or null. - */ - public Document getDocument() { - if (parent instanceof Document) { - return (Document) parent; - } - if (parent instanceof Element) { - return ((Element)parent).getDocument(); - } - return null; - } - /** * This returns the textual data within the <code>Comment</code>. * @@ -220,26 +163,4 @@ public final int hashCode() { return super.hashCode(); } - /** - * This will return a clone of this <code>Comment</code>. - * - * @return <code>Object</code> - clone of this <code>Comment</code>. - */ - public Object clone() { - Comment comment = null; - - try { - comment = (Comment) super.clone(); - } catch (CloneNotSupportedException ce) { - // Can't happen - } - - // The text is a reference to a immutable String object - // and is already copied by Object.clone(); - - // parent reference is copied by Object.clone() - // and must be set to null - comment.parent = null; - return comment; - } } diff --git a/core/src/java/org/jdom/ContentList.java b/core/src/java/org/jdom/ContentList.java index 423048afe..f76a965e1 100644 --- a/core/src/java/org/jdom/ContentList.java +++ b/core/src/java/org/jdom/ContentList.java @@ -1,6 +1,6 @@ /*-- - $Id: ContentList.java,v 1.31 2004/02/05 09:35:56 jhunter Exp $ + $Id: ContentList.java,v 1.32 2004/02/06 03:39:02 jhunter Exp $ Copyright (C) 2000 Jason Hunter & Brett McLaughlin. All rights reserved. @@ -72,15 +72,15 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * @see ProcessingInstruction * @see Text * - * @version $Revision: 1.31 $, $Date: 2004/02/05 09:35:56 $ + * @version $Revision: 1.32 $, $Date: 2004/02/06 03:39:02 $ * @author Alex Rosen * @author Philippe Riand * @author Bradley S. Huffman */ -class ContentList extends AbstractList implements java.io.Serializable { +final class ContentList extends AbstractList implements java.io.Serializable { private static final String CVS_ID = - "@(#) $RCSfile: ContentList.java,v $ $Revision: 1.31 $ $Date: 2004/02/05 09:35:56 $ $Name: $"; + "@(#) $RCSfile: ContentList.java,v $ $Revision: 1.32 $ $Date: 2004/02/06 03:39:02 $ $Name: $"; private static final int INITIAL_ARRAY_SIZE = 5; @@ -99,28 +99,14 @@ class ContentList extends AbstractList implements java.io.Serializable { /** Our backing list */ // protected ArrayList list; - private Object elementData[]; + private Child elementData[]; private int size; /** Document or Element this list belongs to */ - private Object parent; + private Parent parent; /** Force either a Document or Element parent */ - private ContentList() { } - - /** - * Create a new instance of the ContentList representing - * Document content - */ - ContentList(Document document) { - this.parent = document; - } - - /** - * Create a new instance of the ContentList representing - * Element content - */ - ContentList(Element parent) { + ContentList(Parent parent) { this.parent = parent; } @@ -134,101 +120,16 @@ private ContentList() { } * throws IndexOutOfBoundsException if index < 0 || index > size() */ public void add(int index, Object obj) { - if (obj instanceof Element) { - add(index, (Element) obj); - } - else if (obj instanceof Text) { - add(index, (Text) obj); - } - else if (obj instanceof Comment) { - add(index, (Comment) obj); - } - else if (obj instanceof ProcessingInstruction) { - add(index, (ProcessingInstruction) obj); - } - else if (obj instanceof EntityRef) { - add(index, (EntityRef) obj); - } - else if (obj instanceof DocType) { - add(index, (DocType) obj); - } - else { - if (obj == null) { - throw new IllegalAddException("Cannot add null object"); - } - else { - throw new IllegalAddException("Class " + - obj.getClass().getName() + - " is of unrecognized type and cannot be added"); - } - } - } - - /** - * Check and add the <code>Element</code> to this list at - * the given index. - * - * @param index index where to add <code>Element</code> - * @param element <code>Element</code> to add - */ - void add(int index, Element element) { - if (element == null) { + if (obj == null) { throw new IllegalAddException("Cannot add null object"); } - - if (element.getParent() != null) { - Parent p = element.getParent(); - if (p instanceof Document) { - throw new IllegalAddException(element, - "The element is the root element of another document"); - } - else { - throw new IllegalAddException( - "The element already has an existing parent \"" + - ((Element)p).getQualifiedName() + "\""); - } - } - - if (element == parent) { - throw new IllegalAddException( - "The element cannot be added to itself"); - } - - if ((parent instanceof Element) && - ((Element) parent).isAncestor(element)) { - throw new IllegalAddException( - "The element cannot be added as a descendent of itself"); - } - - if (index<0 || index>size) { - throw new IndexOutOfBoundsException("Index: " + index + - " Size: " + size()); - } - - if (parent instanceof Document) { - if (indexOfFirstElement() >= 0) { - throw new IllegalAddException( - "Cannot add a second root element, only one is allowed"); - } - if (indexOfDocType() > index) { - throw new IllegalAddException( - "A root element cannot be added before the DocType"); - } - element.setParent((Document) parent); - } - else { - element.setParent((Element) parent); - } - - ensureCapacity(size+1); - if( index==size ) { - elementData[size++] = element; + if ((obj instanceof Child)) { + add(index, (Child) obj); } else { - System.arraycopy(elementData, index, elementData, index + 1, size - index); - elementData[index] = element; - size++; + throw new IllegalAddException("Class " + + obj.getClass().getName() + + " is of unrecognized type and cannot be added"); } - modCount++; } /** @@ -236,255 +137,36 @@ void add(int index, Element element) { * the given index. * * @param index index where to add <code>Element</code> - * @param doctype <code>DocType</code> to add + * @param child <code>Element</code> to add */ - void add(int index, DocType doctype) { - if (doctype == null) { + void add(int index, Child child) { + if (child == null) { throw new IllegalAddException("Cannot add null object"); } + parent.canContain(child, index); - if (doctype.getParent() != null) { - throw new IllegalAddException(doctype, - "The doctype already has an existing document"); - } - - if (index < 0 || index > size) { - throw new IndexOutOfBoundsException("Index: " + index + - " Size: " + size()); - } - - if (parent instanceof Element) { - throw new IllegalAddException( - "A DocType is not allowed except at the document level"); - } - - int firstElt = indexOfFirstElement(); - if (firstElt != -1 && firstElt < index) { - throw new IllegalAddException( - "A DocType cannot be added after the root element"); - } - - if (parent instanceof Document) { - if (indexOfDocType() >= 0) { - throw new IllegalAddException( - "Cannot add a second doctype, only one is allowed"); - } - doctype.setParent((Document) parent); - } - - ensureCapacity(size + 1); - if (index == size) { - elementData[size++] = doctype; - } - else { - System.arraycopy(elementData, index, elementData, index + 1, size - index); - elementData[index] = doctype; - size++; - } - modCount++; - } - - /** - * Check and add the <code>Comment</code> to this list at - * the given index. - * - * @param index index where to add <code>Comment</code> - * @param comment <code>Comment</code> to add - */ - void add(int index, Comment comment) { - if (comment == null) { - throw new IllegalAddException("Cannot add null object"); - } - - if (comment.getParent() != null) { - Parent p = comment.getParent(); + if (child.getParent() != null) { + Parent p = child.getParent(); if (p instanceof Document) { - throw new IllegalAddException(comment, - "The comment is already attached to a document"); + throw new IllegalAddException((Element)child, + "The Child already has an existing parent document"); } else { throw new IllegalAddException( - "The comment already has an existing parent \"" + + "The Child already has an existing parent \"" + ((Element)p).getQualifiedName() + "\""); } } - if (index<0 || index>size) { - throw new IndexOutOfBoundsException("Index: " + index + - " Size: " + size()); - } - - // XXX We can simplify this - if (parent instanceof Document) { - comment.setParent((Document) parent); - } - else { - comment.setParent((Element) parent); - } - - ensureCapacity(size+1); - if( index==size ) { - elementData[size++] = comment; - } else { - System.arraycopy(elementData, index, elementData, index + 1, size - index); - elementData[index] = comment; - size++; - } - modCount++; - } - - /** - * Check and add the <code>ProcessingInstruction</code> to this list at - * the given index. - * - * @param index index where to add <code>ProcessingInstruction</code> - * @param pi <code>ProcessingInstruction</code> to add - */ - void add(int index, ProcessingInstruction pi) { - if (pi == null) { - throw new IllegalAddException("Cannot add null object"); - } - - if (pi.getParent() != null) { - Parent p = pi.getParent(); - if (p instanceof Document) { - throw new IllegalAddException( - "The PI is already attached to a document"); - } - else { - throw new IllegalAddException( - "The PI already has an existing parent \"" + - ((Element)p).getQualifiedName() + "\""); - } - } - - if (index<0 || index>size) { - throw new IndexOutOfBoundsException("Index: " + index + - " Size: " + size()); - } - - // XXX We can simplify this - if (parent instanceof Document) { - pi.setParent((Document) parent); - } - else { - pi.setParent((Element) parent); - } - - ensureCapacity(size+1); - if( index==size ) { - elementData[size++] = pi; - } else { - System.arraycopy(elementData, index, elementData, index + 1, size - index); - elementData[index] = pi; - size++; - } - modCount++; - } - - /** - * Check and add the <code>CDATA</code> to this list at - * the given index. - * - * @param index index where to add <code>CDATA</code> - * @param cdata <code>CDATA</code> to add - */ - void add(int index, CDATA cdata) { - if (cdata == null) { - throw new IllegalAddException("Cannot add null object"); - } - - if (parent instanceof Document) { - throw new IllegalAddException( - "A CDATA is not allowed at the document root"); - } - - if (cdata.getParent() != null) { - throw new IllegalAddException( - "The CDATA already has an existing parent \"" + - ((Element)cdata.getParent()).getQualifiedName() + "\""); - } - - if (index<0 || index>size) { - throw new IndexOutOfBoundsException("Index: " + index + - " Size: " + size()); - } - - cdata.setParent((Element) parent); - - ensureCapacity(size+1); - if( index==size ) { - elementData[size++] = cdata; - } else { - System.arraycopy(elementData, index, elementData, index + 1, size - index); - elementData[index] = cdata; - size++; - } - modCount++; - } - - /** - * Check and add the <code>Text</code> to this list at - * the given index. - * - * @param index index where to add <code>Text</code> - * @param text <code>Text</code> to add - */ - void add(int index, Text text) { - if (text == null) { - throw new IllegalAddException("Cannot add null object"); - } - - if (parent instanceof Document) { - throw new IllegalAddException( - "A Text not allowed at the document root"); - } - - if (text.getParent() != null) { - throw new IllegalAddException( - "The Text already has an existing parent \"" + - ((Element)text.getParent()).getQualifiedName() + "\""); - } - - if (index<0 || index>size) { - throw new IndexOutOfBoundsException("Index: " + index + - " Size: " + size()); - } - - text.setParent((Element) parent); - - ensureCapacity(size+1); - if( index==size ) { - elementData[size++] = text; - } else { - System.arraycopy(elementData, index, elementData, index + 1, size - index); - elementData[index] = text; - size++; - } - modCount++; - } - - /** - * Check and add the <code>EntityRef</code> to this list at - * the given index. - * - * @param index index where to add <code>Entity</code> - * @param entity <code>Entity</code> to add - */ - void add(int index, EntityRef entity) { - if (entity == null) { - throw new IllegalAddException("Cannot add null object"); - } - - if (parent instanceof Document) { + if (child == parent) { throw new IllegalAddException( - "An EntityRef is not allowed at the document root"); + "The Element cannot be added to itself"); } - if (entity.getParent() != null) { + if ((parent instanceof Element && child instanceof Element) && + ((Element) parent).isAncestor((Element)child)) { throw new IllegalAddException( - "The EntityRef already has an existing parent \"" + - ((Element)entity.getParent()).getQualifiedName() + "\""); + "The Element cannot be added as a descendent of itself"); } if (index<0 || index>size) { @@ -492,14 +174,14 @@ void add(int index, EntityRef entity) { " Size: " + size()); } - entity.setParent((Element) parent); + child.setParent(parent); ensureCapacity(size+1); if( index==size ) { - elementData[size++] = entity; + elementData[size++] = child; } else { System.arraycopy(elementData, index, elementData, index + 1, size - index); - elementData[index] = entity; + elementData[index] = child; size++; } modCount++; @@ -580,7 +262,7 @@ public void clear() { * @param collection The collection to use. */ void clearAndSet(Collection collection) { - Object[] old = elementData; + Child[] old = elementData; int oldSize = size; elementData = null; @@ -615,7 +297,7 @@ void clearAndSet(Collection collection) { */ void ensureCapacity(int minCapacity) { if( elementData==null ) { - elementData = new Object[Math.max(minCapacity, INITIAL_ARRAY_SIZE)]; + elementData = new Child[Math.max(minCapacity, INITIAL_ARRAY_SIZE)]; } else { int oldCapacity = elementData.length; if (minCapacity > oldCapacity) { @@ -623,7 +305,7 @@ void ensureCapacity(int minCapacity) { int newCapacity = (oldCapacity * 3)/2 + 1; if (newCapacity < minCapacity) newCapacity = minCapacity; - elementData = new Object[newCapacity]; + elementData = new Child[newCapacity]; System.arraycopy(oldData, 0, elementData, 0, size); } } diff --git a/core/src/java/org/jdom/DocType.java b/core/src/java/org/jdom/DocType.java index 3db130adf..12b36bc8a 100644 --- a/core/src/java/org/jdom/DocType.java +++ b/core/src/java/org/jdom/DocType.java @@ -1,6 +1,6 @@ /*-- - $Id: DocType.java,v 1.26 2003/05/20 21:53:59 jhunter Exp $ + $Id: DocType.java,v 1.27 2004/02/06 03:39:03 jhunter Exp $ Copyright (C) 2000 Jason Hunter & Brett McLaughlin. All rights reserved. @@ -62,12 +62,12 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * * @author Brett McLaughlin * @author Jason Hunter - * @version $Revision: 1.26 $, $Date: 2003/05/20 21:53:59 $ + * @version $Revision: 1.27 $, $Date: 2004/02/06 03:39:03 $ */ -public class DocType implements Child { +public class DocType extends Child { private static final String CVS_ID = - "@(#) $RCSfile: DocType.java,v $ $Revision: 1.26 $ $Date: 2003/05/20 21:53:59 $ $Name: $"; + "@(#) $RCSfile: DocType.java,v $ $Revision: 1.27 $ $Date: 2004/02/06 03:39:03 $ $Name: $"; /** The element being constrained */ protected String elementName; @@ -78,9 +78,6 @@ public class DocType implements Child { /** The system ID of the DOCTYPE */ protected String systemID; - /** The document having this DOCTYPE */ - protected Document parent; - /** The internal subset of the DOCTYPE */ protected String internalSubset; @@ -236,28 +233,6 @@ public DocType setSystemID(String systemID) { return this; } - public Child detach() { - if (parent != null) { - parent.removeContent(this); - } - return this; - } - - /** - * This retrieves the owning <code>{@link Document}</code> for - * this DocType, or null if not a currently a member of a - * <code>{@link Document}</code>. - * - * @return <code>Document</code> owning this DocType, or null. - */ - public Document getDocument() { - return parent; - } - - public Parent getParent() { - return parent; - } - /** * Returns the empty string since doctypes don't have an XPath * 1.0 string value. @@ -267,17 +242,6 @@ public String getValue() { return ""; // doctypes don't have an XPath string value } - /** - * This sets the <code>{@link Document}</code> holding this doctype. - * - * @param parent parent document holding this doctype - * @return <code>Document</code> this <code>DocType</code> modified - */ - protected DocType setParent(Document parent) { - this.parent = parent; - return this; - } - /** * This sets the data for the internal subset. * @@ -335,24 +299,4 @@ public final int hashCode() { return super.hashCode(); } - /** - * This will return a clone of this <code>DocType</code>. - * - * @return <code>Object</code> - clone of this <code>DocType</code>. - */ - public Object clone() { - DocType docType = null; - - try { - docType = (DocType) super.clone(); - } catch (CloneNotSupportedException ce) { - // Can't happen - } - - docType.parent = null; - - // elementName, publicID, and systemID are all immutable - // (Strings) and references are copied by Object.clone() - return docType; - } } diff --git a/core/src/java/org/jdom/Document.java b/core/src/java/org/jdom/Document.java index 71ccfcac4..f952bb082 100644 --- a/core/src/java/org/jdom/Document.java +++ b/core/src/java/org/jdom/Document.java @@ -1,6 +1,6 @@ /*-- - $Id: Document.java,v 1.74 2004/02/05 10:45:33 jhunter Exp $ + $Id: Document.java,v 1.75 2004/02/06 03:39:03 jhunter Exp $ Copyright (C) 2000 Jason Hunter & Brett McLaughlin. All rights reserved. @@ -63,7 +63,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * An XML document. Methods allow access to the root element as well as the * {@link DocType} and other document-level information. * - * @version $Revision: 1.74 $, $Date: 2004/02/05 10:45:33 $ + * @version $Revision: 1.75 $, $Date: 2004/02/06 03:39:03 $ * @author Brett McLaughlin * @author Jason Hunter * @author Jools Enticknap @@ -72,7 +72,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT public class Document implements Parent { private static final String CVS_ID = - "@(#) $RCSfile: Document.java,v $ $Revision: 1.74 $ $Date: 2004/02/05 10:45:33 $ $Name: $"; + "@(#) $RCSfile: Document.java,v $ $Revision: 1.75 $ $Date: 2004/02/06 03:39:03 $ $Name: $"; /** * This document's content including comments, PIs, a possible @@ -677,4 +677,49 @@ public Document(List newContent, DocType docType) { setContent(newContent); setDocType(docType); } + + /** + * @see org.jdom.Parent#getDocument() + */ + public Document getDocument() { + return this; + } + + /** + * @see org.jdom.ContentList#add(int, org.jdom.Child) + */ + public void canContain(Child child, int index) throws IllegalAddException { + if (child instanceof Element) { + if (child instanceof Element && content.indexOfFirstElement() >= 0) { + throw new IllegalAddException( + "Cannot add a second root element, only one is allowed"); + } + if (child instanceof Element && content.indexOfDocType() > index) { + throw new IllegalAddException( + "A root element cannot be added before the DocType"); + } + } + if (child instanceof DocType) { + if (content.indexOfDocType() >= 0) { + throw new IllegalAddException( + "Cannot add a second doctype, only one is allowed"); + } + int firstElt = content.indexOfFirstElement(); + if (firstElt != -1 && firstElt < index) { + throw new IllegalAddException( + "A DocType cannot be added after the root element"); + } + } + if (child instanceof CDATA) { + throw new IllegalAddException("A CDATA is not allowed at the document root"); + } + + if (child instanceof Text) { + throw new IllegalAddException("A Text is not allowed at the document root"); + } + + if (child instanceof EntityRef) { + throw new IllegalAddException("An EntityRef is not allowed at the document root"); + } + } } diff --git a/core/src/java/org/jdom/Element.java b/core/src/java/org/jdom/Element.java index f9a46a9bc..ec4e9c197 100644 --- a/core/src/java/org/jdom/Element.java +++ b/core/src/java/org/jdom/Element.java @@ -1,6 +1,6 @@ /*-- - $Id: Element.java,v 1.139 2003/06/18 02:59:44 jhunter Exp $ + $Id: Element.java,v 1.140 2004/02/06 03:39:03 jhunter Exp $ Copyright (C) 2000 Jason Hunter & Brett McLaughlin. All rights reserved. @@ -66,7 +66,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * elements and content, directly access the element's textual content, * manipulate its attributes, and manage namespaces. * - * @version $Revision: 1.139 $, $Date: 2003/06/18 02:59:44 $ + * @version $Revision: 1.140 $, $Date: 2004/02/06 03:39:03 $ * @author Brett McLaughlin * @author Jason Hunter * @author Lucas Gonze @@ -78,10 +78,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * @author Alex Rosen * @author Bradley S. Huffman */ -public class Element implements Parent, Child { +public class Element extends Child implements Parent { private static final String CVS_ID = - "@(#) $RCSfile: Element.java,v $ $Revision: 1.139 $ $Date: 2003/06/18 02:59:44 $ $Name: $"; + "@(#) $RCSfile: Element.java,v $ $Revision: 1.140 $ $Date: 2004/02/06 03:39:03 $ $Name: $"; private static final int INITIAL_ARRAY_SIZE = 5; @@ -386,16 +386,6 @@ public List getAdditionalNamespaces() { return Collections.unmodifiableList(additionalNamespaces); } - /** - * Returns the parent of this element or null if unattached. The parent - * can be either a Document or Element. - * - * @return parent of this element - */ - public Parent getParent() { - return parent; - } - /** * Returns the XPath 1.0 string value of this element, which is the * complete, ordered content of all text node descendants of this element @@ -417,34 +407,6 @@ public String getValue() { return buffer.toString(); } - /** - * Sets the parent of this element. The caller is responsible for removing - * any pre-existing parentage. - * - * @param parent new parent element - * @return the target element - */ - protected Element setParent(Parent parent) { - this.parent = parent; - return this; - } - - /** - * Detaches the element from its element parent or document, or does nothing - * if the element has no parent. - * - * @return the target element - */ - public Child detach() { - if (parent instanceof Element) { - parent.removeContent(this); - } - else if (parent instanceof Document) { - ((Document) parent).detachRootElement(); - } - return this; - } - /** * Returns whether this element is a root element. This can be used in * tandem with {@link #getParent} to determine if an element has any @@ -474,23 +436,6 @@ public int indexOf(Child child) { // return -1; // } - /** - * Returns the owning document for this element, or null if it's not a - * currently a member of a document. - * - * @return the document owning this element, or null if - * none - */ - public Document getDocument() { - if (parent instanceof Document) { - return (Document) parent; - } - if (parent instanceof Element) { - return ((Element)parent).getDocument(); - } - - return null; - } /** * Returns the textual content directly held under this element as a string. @@ -1436,18 +1381,15 @@ public Object clone() { Element element = null; - try { element = (Element) super.clone(); - } catch (CloneNotSupportedException ce) { - // Can't happen - } // name and namespace are references to immutable objects // so super.clone() handles them ok // Reference to parent is copied by super.clone() // (Object.clone()) so we have to remove it - element.parent = null; + // Actually, super is a Child, which has already detached in the clone(). + // element.parent = null; // Reference to content list and attribute lists are copyed by // super.clone() so we set it new lists if the original had lists @@ -1770,4 +1712,12 @@ public boolean removeChildren(String name, Namespace ns) { return deletedSome; } + + public void canContain(Child child, int index) throws IllegalAddException { + if (child instanceof DocType) { + throw new IllegalAddException( + "A DocType is not allowed except at the document level"); + } + } + } diff --git a/core/src/java/org/jdom/EntityRef.java b/core/src/java/org/jdom/EntityRef.java index 425ad2776..f76d010e9 100644 --- a/core/src/java/org/jdom/EntityRef.java +++ b/core/src/java/org/jdom/EntityRef.java @@ -1,36 +1,36 @@ -/*-- +/*-- - $Id: EntityRef.java,v 1.16 2003/06/04 17:40:52 jhunter Exp $ + $Id: EntityRef.java,v 1.17 2004/02/06 03:39:03 jhunter Exp $ Copyright (C) 2000 Jason Hunter & Brett McLaughlin. All rights reserved. - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions, and the disclaimer that follows - these conditions in the documentation and/or other materials + notice, this list of conditions, and the disclaimer that follows + these conditions in the documentation and/or other materials provided with the distribution. 3. The name "JDOM" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact <request_AT_jdom_DOT_org>. - + 4. Products derived from this software may not be called "JDOM", nor may "JDOM" appear in their name, without prior written permission from the JDOM Project Management <request_AT_jdom_DOT_org>. - - In addition, we request (but do not require) that you include in the - end-user documentation provided with the redistribution and/or in the + + In addition, we request (but do not require) that you include in the + end-user documentation provided with the redistribution and/or in the software itself an acknowledgement equivalent to the following: "This product includes software developed by the JDOM Project (http://www.jdom.org/)." - Alternatively, the acknowledgment may be graphical using the logos + Alternatively, the acknowledgment may be graphical using the logos available at http://www.jdom.org/images/logos. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED @@ -46,12 +46,12 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - This software consists of voluntary contributions made by many - individuals on behalf of the JDOM Project and was originally + This software consists of voluntary contributions made by many + individuals on behalf of the JDOM Project and was originally created by Jason Hunter <jhunter_AT_jdom_DOT_org> and Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information on the JDOM Project, please see <http://www.jdom.org/>. - + */ package org.jdom; @@ -59,16 +59,16 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT /** * An XML entity reference. Methods allow the user to manage its name, public * id, and system id. - * - * @version $Revision: 1.16 $, $Date: 2003/06/04 17:40:52 $ + * + * @version $Revision: 1.17 $, $Date: 2004/02/06 03:39:03 $ * @author Brett McLaughlin * @author Jason Hunter * @author Philip Nelson */ -public class EntityRef implements Child { +public class EntityRef extends Child { - private static final String CVS_ID = - "@(#) $RCSfile: EntityRef.java,v $ $Revision: 1.16 $ $Date: 2003/06/04 17:40:52 $ $Name: $"; + private static final String CVS_ID = + "@(#) $RCSfile: EntityRef.java,v $ $Revision: 1.17 $ $Date: 2004/02/06 03:39:03 $ $Name: $"; /** The name of the <code>EntityRef</code> */ protected String name; @@ -79,9 +79,6 @@ public class EntityRef implements Child { /** The SystemID of the <code>EntityRef</code> */ protected String systemID; - /** Parent element or null if none */ - protected Element parent; - /** * Default, no-args constructor for implementations to use if needed. */ @@ -129,43 +126,6 @@ public EntityRef(String name, String publicID, String systemID) { setSystemID(systemID); } - /** - * This will return a clone of this <code>EntityRef</code>. - * - * @return <code>Object</code> - clone of this <code>EntityRef</code>. - */ - public Object clone() { - EntityRef entity = null; - - try { - entity = (EntityRef) super.clone(); - } catch (CloneNotSupportedException ce) { - // Can't happen - } - - // name is a reference to an immutable (String) object - // and is copied by Object.clone() - - // The parent reference is copied by Object.clone(), so - // must set to null - entity.parent = null; - - return entity; - } - - /** - * This detaches the <code>Entity</code> from its parent, or does nothing - * if the <code>Entity</code> has no parent. - * - * @return <code>Entity</code> - this <code>Entity</code> modified. - */ - public Child detach() { - if (parent != null) { - parent.removeContent(this); - } - return this; - } - /** * This tests for equality of this <code>Entity</code> to the supplied * <code>Object</code>. @@ -178,21 +138,6 @@ public final boolean equals(Object ob) { return (ob == this); } - /** - * This retrieves the owning <code>{@link Document}</code> for - * this Entity, or null if not a currently a member of a - * <code>{@link Document}</code>. - * - * @return <code>Document</code> owning this Entity, or null. - */ - public Document getDocument() { - if (parent != null) { - return parent.getDocument(); - } - - return null; - } - /** * This returns the name of the <code>EntityRef</code>. * @@ -202,16 +147,6 @@ public String getName() { return name; } - /** - * This will return the parent of this <code>EntityRef</code>. - * If there is no parent, then this returns <code>null</code>. - * - * @return parent of this <code>EntityRef</code> - */ - public Parent getParent() { - return parent; - } - /** * Returns the empty string since entity references don't have an XPath * 1.0 string value. @@ -250,17 +185,6 @@ public final int hashCode() { return super.hashCode(); } - /** - * This will set the parent of this <code>Entity</code>. - * - * @param parent <code>Element</code> to be new parent. - * @return this <code>Entity</code> modified. - */ - protected EntityRef setParent(Element parent) { - this.parent = parent; - return this; - } - /** * This will set the name of this <code>EntityRef</code>. * diff --git a/core/src/java/org/jdom/Parent.java b/core/src/java/org/jdom/Parent.java index 69ccac26d..ca735b70c 100644 --- a/core/src/java/org/jdom/Parent.java +++ b/core/src/java/org/jdom/Parent.java @@ -1,6 +1,6 @@ /*-- - $Id: Parent.java,v 1.6 2004/02/05 10:45:33 jhunter Exp $ + $Id: Parent.java,v 1.7 2004/02/06 03:39:03 jhunter Exp $ Copyright (C) 2000 Brett McLaughlin & Jason Hunter. All rights reserved. @@ -70,7 +70,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * * @author Bradley S. Huffman * @author Jason Hunter - * @version $Revision: 1.6 $, $Date: 2004/02/05 10:45:33 $ + * @version $Revision: 1.7 $, $Date: 2004/02/06 03:39:03 $ */ public interface Parent extends Cloneable, Serializable { @@ -360,4 +360,23 @@ public interface Parent extends Cloneable, Serializable { * @return this parent's parent or null if none */ Parent getParent(); + + /** + * Return this parent's owning document or null if the branch containing + * this parent is currently not attached to a document. + * + * @return this child's owning document or null if none + */ + Document getDocument(); + + /** + * Checks if this parent can contain the given child at the specified + * position, throwing a descriptive IllegalAddException if not and + * simply returning if it's allowed. + * + * @param child the potential child to be added to this parent + * @param index the location for the potential child + * @throws IllegalAddException if the child add isn't allowed + */ + void canContain(Child child, int index) throws IllegalAddException; } diff --git a/core/src/java/org/jdom/ProcessingInstruction.java b/core/src/java/org/jdom/ProcessingInstruction.java index b93051232..94564a3d3 100644 --- a/core/src/java/org/jdom/ProcessingInstruction.java +++ b/core/src/java/org/jdom/ProcessingInstruction.java @@ -1,6 +1,6 @@ /*-- - $Id: ProcessingInstruction.java,v 1.40 2003/05/20 21:53:59 jhunter Exp $ + $Id: ProcessingInstruction.java,v 1.41 2004/02/06 03:39:03 jhunter Exp $ Copyright (C) 2000 Jason Hunter & Brett McLaughlin. All rights reserved. @@ -64,16 +64,16 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * if the data appears akin to an attribute list, can be retrieved as name/value * pairs. * - * @version $Revision: 1.40 $, $Date: 2003/05/20 21:53:59 $ + * @version $Revision: 1.41 $, $Date: 2004/02/06 03:39:03 $ * @author Brett McLaughlin * @author Jason Hunter * @author Steven Gould */ -public class ProcessingInstruction implements Child { +public class ProcessingInstruction extends Child { private static final String CVS_ID = - "@(#) $RCSfile: ProcessingInstruction.java,v $ $Revision: 1.40 $ $Date: 2003/05/20 21:53:59 $ $Name: $"; + "@(#) $RCSfile: ProcessingInstruction.java,v $ $Revision: 1.41 $ $Date: 2004/02/06 03:39:03 $ $Name: $"; /** The target of the PI */ protected String target; @@ -84,9 +84,6 @@ public class ProcessingInstruction implements Child { /** The data for the PI in name/value pairs */ protected Map mapData; - /** Parent element, document, or null if none */ - protected Parent parent; - /** * Default, no-args constructor for implementations * to use if needed. @@ -139,19 +136,6 @@ public ProcessingInstruction setTarget(String newTarget) { return this; } - /** - * This will return the parent of this <code>ProcessingInstruction</code>. - * If there is no parent, then this returns <code>null</code>. - * - * @return parent of this <code>ProcessingInstruction</code> - */ - public Parent getParent() { - if (parent instanceof Element) { - return (Element) parent; - } - return null; - } - /** * Returns the XPath 1.0 string value of this element, which is the * data of this PI. @@ -162,49 +146,6 @@ public String getValue() { return rawData; } - /** - * <p> - * This will set the parent of this <code>ProcessingInstruction</code>. - * </p> - * - * @param parent <code>Element</code> to be new parent. - * @return this <code>ProcessingInstruction</code> modified. - */ - protected ProcessingInstruction setParent(Parent parent) { - this.parent = parent; - return this; - } - - /** - * This detaches the PI from its parent, or does nothing if the - * PI has no parent. - * - * @return <code>ProcessingInstruction</code> - this - * <code>ProcessingInstruction</code> modified. - */ - public Child detach() { - if (parent != null) { - parent.removeContent(this); - } - return this; - } - - /** - * This retrieves the owning <code>{@link Document}</code> for - * this PI, or null if not a currently a member of a - * <code>{@link Document}</code>. - * - * @return <code>Document</code> owning this PI, or null. - */ - public Document getDocument() { - if (parent instanceof Document) { - return (Document) parent; - } - if (parent instanceof Element) { - return ((Element)parent).getDocument(); - } - return null; - } /** * This will retrieve the target of the PI. @@ -593,26 +534,15 @@ public final int hashCode() { * <code>ProcessingInstruction</code>. */ public Object clone() { - ProcessingInstruction pi = null; - - try { - pi = (ProcessingInstruction) super.clone(); - } catch (CloneNotSupportedException ce) { - // Can't happen - } + ProcessingInstruction pi = (ProcessingInstruction) super.clone(); // target and rawdata are immutable and references copied by // Object.clone() - // parent reference is copied by Object.clone(), so - // must set to null - pi.parent = null; - // Create a new Map object for the clone (since Map isn't Cloneable) if (mapData != null) { pi.mapData = parseData(rawData); } - return pi; } } diff --git a/core/src/java/org/jdom/Text.java b/core/src/java/org/jdom/Text.java index 521c33e98..627b433f2 100644 --- a/core/src/java/org/jdom/Text.java +++ b/core/src/java/org/jdom/Text.java @@ -1,6 +1,6 @@ /*-- - $Id: Text.java,v 1.18 2003/05/29 02:47:40 jhunter Exp $ + $Id: Text.java,v 1.19 2004/02/06 03:39:03 jhunter Exp $ Copyright (C) 2000 Jason Hunter & Brett McLaughlin. All rights reserved. @@ -61,15 +61,15 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * representing text. Text makes no guarantees about the underlying textual * representation of character data, but does expose that data as a Java String. * - * @version $Revision: 1.18 $, $Date: 2003/05/29 02:47:40 $ + * @version $Revision: 1.19 $, $Date: 2004/02/06 03:39:03 $ * @author Brett McLaughlin * @author Jason Hunter * @author Bradley S. Huffman */ -public class Text implements Child { +public class Text extends Child { private static final String CVS_ID = - "@(#) $RCSfile: Text.java,v $ $Revision: 1.18 $ $Date: 2003/05/29 02:47:40 $ $Name: $"; + "@(#) $RCSfile: Text.java,v $ $Revision: 1.19 $ $Date: 2004/02/06 03:39:03 $ $Name: $"; static final String EMPTY_STRING = ""; @@ -80,7 +80,7 @@ public class Text implements Child { protected String value; /** This <code>Text</code> node's parent. */ - protected Element parent; + protected Parent parent; /** * This is the protected, no-args constructor standard in all JDOM @@ -230,16 +230,6 @@ public void append(Text text) { value += text.getText(); } - /** - * This will return the parent of this <code>Text</code> node, which - * is always a JDOM <code>{@link Element}</code>. - * - * @return <code>Element</code> - this node's parent. - */ - public Parent getParent() { - return parent; - } - /** * Returns the XPath 1.0 string value of this element, which is the * text itself. @@ -250,20 +240,6 @@ public String getValue() { return value; } - /** - * This retrieves the owning <code>{@link Document}</code> for - * this <code>Text</code>, or null if not a currently a member - * of a <code>{@link Document}</code>. - * - * @return <code>Document</code> owning this <code>Text</code>, or null. - */ - public Document getDocument() { - if (parent != null) { - return parent.getDocument(); - } - return null; - } - /** * This will set the parent of the <code>Text</code> node to the supplied * <code>{@link Element}</code>. This method is intentionally left as @@ -276,24 +252,11 @@ public Document getDocument() { * * @param parent parent for this node. */ - protected Text setParent(Element parent) { + protected Child setParent(Parent parent) { this.parent = parent; return this; } - /** - * Detaches the <code>Text</code> from its parent, or does nothing - * if the <code>Text</code> has no parent. - * - * @return <code>Text</code> - this <code>Text</code> modified. - */ - public Child detach() { - if (parent != null) { - parent.removeContent(this); - } - return this; - } - /** * This returns a <code>String</code> representation of the * <code>Text</code> node, suitable for debugging. If the XML @@ -328,17 +291,8 @@ public final int hashCode() { * @return <code>Text</code> - cloned node. */ public Object clone() { - Text text = null; - - try { - text = (Text)super.clone(); - } catch (CloneNotSupportedException ce) { - // Can't happen - } - - text.parent = null; + Text text = (Text)super.clone(); text.value = value; - return text; }
a4ea5ec772783547025169e51f3471b728bcf881
Valadoc
ctyperesolver, virtual signals: register function pointer names
a
https://github.com/GNOME/vala/
diff --git a/src/libvaladoc/ctyperesolver.vala b/src/libvaladoc/ctyperesolver.vala index c5604276a3..3c30dfdf54 100644 --- a/src/libvaladoc/ctyperesolver.vala +++ b/src/libvaladoc/ctyperesolver.vala @@ -318,6 +318,10 @@ public class Valadoc.CTypeResolver : Visitor { string cname = item.get_cname (); register_symbol (parent_cname+"::"+cname, item); + if (item.is_virtual) { + // only supported by classes + register_symbol (parent_cname + "Class." + item.name, item); + } Collection<Interface> interfaces = null; Collection<Class> classes = null; @@ -354,28 +358,6 @@ public class Valadoc.CTypeResolver : Visitor { // Allow to resolve invalid links: register_symbol (parent_cname + "." + item.name, item); - - - Collection<Interface> interfaces = null; - Collection<Class> classes = null; - - if (item.parent is Interface) { - interfaces = ((Api.Interface) item.parent).get_known_related_interfaces (); - classes = ((Api.Interface) item.parent).get_known_implementations (); - } else if (item.parent is Class) { - interfaces = ((Api.Class) item.parent).get_known_derived_interfaces (); - classes = ((Api.Class) item.parent).get_known_child_classes (); - } - - foreach (Interface iface in interfaces) { - register_symbol (iface.get_cname () + "Iface." + item.name, item); - register_symbol (iface.get_cname () + "." + item.name, item); - } - - foreach (Class cl in classes) { - register_symbol (cl.get_cname () + "Class." + item.name, item); - register_symbol (cl.get_cname () + "." + item.name, item); - } } register_symbol (item.get_cname (), item);