LENS-1527 : Fix session restore issue
[lens.git] / lens-server-api / src / main / java / org / apache / lens / server / api / session / SessionService.java
1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 package org.apache.lens.server.api.session;
21
22 import java.util.List;
23 import java.util.Map;
24
25 import org.apache.lens.api.LensSessionHandle;
26 import org.apache.lens.api.session.SessionPerUserInfo;
27 import org.apache.lens.api.session.UserSessionInfo;
28 import org.apache.lens.server.api.error.LensException;
29
30 public interface SessionService {
31
32 /** Name of session service */
33 String NAME = "session";
34
35 /**
36 * Open session.
37 *
38 * @param username the username
39 * @param password the password
40 * @param database Set current database to the supplied value
41 * @param configuration the configuration
42 * @return the lens session handle
43 * @throws LensException the lens exception
44 */
45
46 LensSessionHandle openSession(String username, String password, String database,
47 Map<String, String> configuration)
48 throws LensException;
49
50 /**
51 * Restore session from previous instance of lens server.
52 *
53 * @param sessionHandle the session handle
54 * @param userName the user name
55 * @param password the password
56 * @throws LensException the lens exception
57 */
58
59 void restoreSession(LensSessionHandle sessionHandle, String userName, String password,
60 Map<String, String> configuration) throws LensException;
61
62 /**
63 * Close session.
64 *
65 * @param sessionHandle the session handle
66 * @throws LensException the lens exception
67 */
68
69 void closeSession(LensSessionHandle sessionHandle) throws LensException;
70
71 /**
72 * Close idle sessions.
73 *
74 * @throws LensException the lens exception
75 */
76
77 void cleanupIdleSessions() throws LensException;
78 /**
79 * Adds the resource.
80 *
81 * @param sessionHandle the session handle
82 * @param type the type
83 * @param path the path
84 */
85
86 void addResource(LensSessionHandle sessionHandle, String type, String path);
87
88 /**
89 * Delete resource.
90 *
91 * @param sessionHandle the session handle
92 * @param type the type
93 * @param path the path
94 */
95
96 void deleteResource(LensSessionHandle sessionHandle, String type, String path);
97
98
99 /**
100 * Gets the all session parameters.
101 *
102 * @param sessionHandle the sessionid
103 * @param verbose the verbose
104 * @param key the key
105 * @return the all session parameters
106 * @throws LensException the lens exception
107 */
108 List<String> getAllSessionParameters(LensSessionHandle sessionHandle, boolean verbose, String key)
109 throws LensException;
110
111 /**
112 * Sets the session parameter.
113 *
114 * @param sessionHandle the sessionid
115 * @param key the key
116 * @param value the value
117 */
118 void setSessionParameter(LensSessionHandle sessionHandle, String key, String value);
119
120 /**
121 * Lists resources from the session service
122 *
123 * @param sessionHandle the sessionid
124 * @param type the resource type, can be null, file or jar
125 * @return Lists resources for a given resource type.
126 * Lists all resources if resource type is null
127 */
128 List<String> listAllResources(LensSessionHandle sessionHandle, String type);
129
130 /**
131 * Returns true if the session is open
132 */
133 boolean isOpen(LensSessionHandle sessionHandle);
134
135 /**
136 *
137 * @return a list of all sessions
138 */
139 List<UserSessionInfo> getSessionInfo();
140
141 /**
142 *
143 * @return a map of all session per loggedin user
144 */
145 List<SessionPerUserInfo> getSessionPerUser();
146 }