Skip to content

Commit 0bb18c1

Browse files
author
张良凯
committed
init project
0 parents  commit 0bb18c1

File tree

310 files changed

+363123
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

310 files changed

+363123
-0
lines changed

.gitignore

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### PlayFramework template
3+
# Ignore Play! working directory #
4+
bin/
5+
.eclipse
6+
/lib/
7+
/modules
8+
/project/target
9+
tmp/
10+
test-result
11+
server.pid
12+
*.eml
13+
/dist/
14+
.cache
15+
target/
16+
### JetBrains template
17+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
18+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
19+
20+
# User-specific stuff:
21+
.idea/workspace.xml
22+
.idea/tasks.xml
23+
.idea/dictionaries
24+
.idea/vcs.xml
25+
.idea/jsLibraryMappings.xml
26+
.idea
27+
28+
29+
# Sensitive or high-churn files:
30+
.idea/dataSources.ids
31+
.idea/dataSources.xml
32+
.idea/dataSources.local.xml
33+
.idea/sqlDataSources.xml
34+
.idea/dynamic.xml
35+
.idea/uiDesigner.xml
36+
37+
# Gradle:
38+
.idea/gradle.xml
39+
.idea/libraries
40+
41+
# Mongo Explorer plugin:
42+
.idea/mongoSettings.xml
43+
44+
## File-based project format:
45+
*.iws
46+
47+
## Plugin-specific files:
48+
49+
# IntelliJ
50+
/out/
51+
52+
# mpeltonen/sbt-idea plugin
53+
.idea_modules/
54+
55+
# JIRA plugin
56+
atlassian-ide-plugin.xml
57+
58+
# Crashlytics plugin (for Android Studio and IntelliJ)
59+
com_crashlytics_export_strings.xml
60+
crashlytics.properties
61+
crashlytics-build.properties
62+
fabric.properties
63+
64+
### SBT template
65+
# Simple Build Tool
66+
# http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control
67+
68+
/.idea
69+
/.settings
70+
/.sbtserver
71+
target/
72+
/app-2.10
73+
lib_managed/
74+
src_managed/
75+
project/boot/
76+
.history
77+
.cache
78+
### JetBrains template
79+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
80+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
81+
82+
# User-specific stuff:
83+
.idea/workspace.xml
84+
.idea/tasks.xml
85+
.idea/dictionaries
86+
.idea/vcs.xml
87+
.idea/jsLibraryMappings.xml
88+
89+
# Sensitive or high-churn files:
90+
.idea/dataSources.ids
91+
.idea/dataSources.xml
92+
.idea/dataSources.local.xml
93+
.idea/sqlDataSources.xml
94+
.idea/dynamic.xml
95+
.idea/uiDesigner.xml
96+
97+
# Gradle:
98+
.idea/gradle.xml
99+
.idea/libraries
100+
101+
# Mongo Explorer plugin:
102+
.idea/mongoSettings.xml
103+
104+
## File-based project format:
105+
*.iws
106+
107+
## Plugin-specific files:
108+
109+
# IntelliJ
110+
/out/
111+
112+
# mpeltonen/sbt-idea plugin
113+
.idea_modules/
114+
115+
# JIRA plugin
116+
atlassian-ide-plugin.xml
117+
118+
# Crashlytics plugin (for Android Studio and IntelliJ)
119+
com_crashlytics_export_strings.xml
120+
crashlytics.properties
121+
crashlytics-build.properties
122+
fabric.properties
123+
### PlayFramework template
124+
# Ignore Play! working directory #
125+
bin/
126+
.eclipse
127+
/lib/
128+
/modules
129+
/project/target
130+
/target
131+
tmp/
132+
test-result
133+
server.pid
134+
*.eml
135+
/dist/
136+
.cache
137+
### Scala template
138+
*.class
139+
*.log
140+
141+
# sbt specific
142+
.cache
143+
.history
144+
.lib/
145+
dist/*
146+
target/
147+
lib_managed/
148+
src_managed/
149+
project/boot/
150+
project/plugins/project/
151+
152+
# Scala-IDE specific
153+
.scala_dependencies
154+
.worksheet
155+
156+
157+
#/conf/web-site.conf
158+
project/project/

Global.scala

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import play.api._
2+
import play.api.mvc._
3+
import play.api.mvc.Results._
4+
5+
import scala.concurrent.Future
6+
import play.api.Play.current
7+
import com.google.inject._
8+
import models._
9+
10+
object Global extends GlobalSettings {
11+
12+
private lazy val injector = {
13+
Play.isProd match {
14+
case _ => {
15+
Guice.createInjector(new Depend)
16+
}
17+
}
18+
}
19+
20+
21+
// 500 - internal server error
22+
override def onError(request: RequestHeader,ex: Throwable) = {
23+
Future.successful(
24+
InternalServerError(
25+
views.html.errors.fzf()
26+
)
27+
)
28+
}
29+
30+
// 404 - page not found error
31+
override def onHandlerNotFound(request: RequestHeader)= {
32+
Future.successful(
33+
NotFound(
34+
views.html.errors.fzf()
35+
)
36+
)
37+
}
38+
39+
override def getControllerInstance[A](clazz: Class[A]) = {
40+
injector.getInstance(clazz)
41+
}
42+
43+
}

app/controllers/Application.scala

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package controllers
2+
import java.text.SimpleDateFormat
3+
import java.util.Date
4+
5+
import akka.actor.ActorRef
6+
import com.google.inject.Inject
7+
import models._
8+
import models.io.{Message, MessageList, TaskMessage}
9+
import models.metrics.MetricsProvider
10+
import play.api.libs.iteratee.Concurrent.Channel
11+
import play.api.libs.iteratee.{Concurrent, Enumerator, Iteratee}
12+
import play.api.libs.json.{JsValue, Json}
13+
import play.api.mvc._
14+
import play.libs.Akka
15+
import akka.actor._
16+
import akka.event.Logging
17+
import akka.pattern.ask
18+
import akka.util.Timeout
19+
import play.api.Logger
20+
import play.api.mvc._
21+
22+
import scala.concurrent.duration._
23+
import scala.concurrent.{ExecutionContext, Future}
24+
import scala.collection.mutable
25+
import scala.concurrent.ExecutionContext.Implicits.global
26+
import scala.concurrent.stm.{Sink, Source}
27+
28+
/**
29+
* WebSocket and Index
30+
*/
31+
class Application @Inject()(metricsProvider: MetricsProvider)(execute: Execute) extends Controller with Secured {
32+
33+
34+
def index = IsAuthenticated { username => implicit request =>
35+
val rpcInfo: RPCInfo = metricsProvider.getMetricMouled[RPCInfo](RPCInfo.getClass)
36+
val dfsInfo: DFSInfo = metricsProvider.getMetricMouled[DFSInfo](DFSInfo.getClass)
37+
val memInfo: MEMInfo = metricsProvider.getMetricMouled[MEMInfo](MEMInfo.getClass)
38+
Ok(views.html.index(rpcInfo,dfsInfo,memInfo,getNowDate))
39+
}
40+
41+
42+
def startpush = WebSocket.using[String] { implicit request =>
43+
val user: String = request.session.get("email").get
44+
// if(!WebSocketChannel._paths.get(user).isDefined) {
45+
// val (out,channel) = Concurrent.broadcast[String]
46+
// val webSocketChannel = Akka.system.actorOf(WebSocketChannel.props(channel))
47+
// Akka.system.actorOf(MessagePool.props(webSocketChannel),s"MessagePool$user")
48+
// WebSocketChannel._paths += (user-> (out, channel));
49+
50+
// }
51+
52+
val (out,channel) = Concurrent.broadcast[String]
53+
54+
val in = Iteratee.foreach[String] { msg =>
55+
Logger.info(msg)
56+
57+
}
58+
channel.push("daadadad")
59+
(in,out)
60+
}
61+
62+
63+
64+
65+
66+
67+
def msglist =IsAuthenticated { username => implicit request =>
68+
implicit val residentWrites = Json.writes[TaskMessage]
69+
implicit val clusterListWrites = Json.writes[MessageList]
70+
val json: JsValue = Json.toJson(MessageList(Message.getMessages(username)))
71+
Ok(json)
72+
}
73+
74+
def read(appId:String)=Action{
75+
Message.deleteMessage(appId)
76+
Ok(views.html.tasklist())
77+
}
78+
79+
def readall=IsAuthenticated{ username => implicit request =>
80+
Message.deleteAllMessage(username)
81+
Ok(views.html.tasklist())
82+
}
83+
84+
private[this] def getNowDate:String ={
85+
val before = 3*60*60*1000
86+
val currentTime = new Date(System.currentTimeMillis()-before)
87+
currentTime.setMinutes(0)
88+
val formatter = new SimpleDateFormat("yyyy,MM,dd,HH,mm,ss")
89+
formatter.format(currentTime)
90+
}
91+
92+
93+
94+
95+
96+
}

0 commit comments

Comments
 (0)